Skip to content

Commit e33259f

Browse files
committed
Use wide char API for the event log
1 parent 504bf11 commit e33259f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

win32/wsyslog.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
#include "php_win32_globals.h"
6060
#include "wsyslog.h"
61+
#include "codepage.h"
6162

6263
void closelog(void)
6364
{
@@ -92,6 +93,7 @@ void vsyslog(int priority, const char *message, va_list args)
9293
unsigned short etype;
9394
char *tmp = NULL;
9495
DWORD evid;
96+
wchar_t *strsw[2];
9597

9698
/* default event source */
9799
if (INVALID_HANDLE_VALUE == PW32G(log_source))
@@ -110,11 +112,28 @@ void vsyslog(int priority, const char *message, va_list args)
110112
etype = EVENTLOG_WARNING_TYPE;
111113
evid = PHP_SYSLOG_WARNING_TYPE;
112114
}
115+
113116
vspprintf(&tmp, 0, message, args); /* build message */
117+
118+
strsw[0] = php_win32_cp_any_to_w(PW32G(log_header));
119+
strsw[1] = php_win32_cp_any_to_w(tmp);
120+
121+
/* report the event */
122+
if (strsw[0] && strsw[1]) {
123+
ReportEventW(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strsw, NULL);
124+
free(strsw[0]);
125+
free(strsw[1]);
126+
efree(tmp);
127+
return;
128+
}
129+
130+
free(strsw[0]);
131+
free(strsw[1]);
132+
114133
strs[0] = PW32G(log_header); /* write header */
115134
strs[1] = tmp; /* then the message */
116-
/* report the event */
117-
ReportEvent(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL);
135+
136+
ReportEventA(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL);
118137
efree(tmp);
119138
}
120139

0 commit comments

Comments
 (0)