Skip to content

Commit dda70e0

Browse files
committed
Follow up on ed9c16ad5def47d1c8ae2787f53dccfac893ce5f
The event log is not line based, passing the message as is here is just fine. Otherwise we'd create multiple event log items with partial messages.
1 parent a1f3a01 commit dda70e0

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

main/php_syslog.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
#define syslog std_syslog
3838
#endif
3939

40+
#ifdef PHP_WIN32
41+
PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
42+
{
43+
va_list args;
44+
45+
va_start(args, format);
46+
vsyslog(priority, format, args);
47+
va_end(args);
48+
}
49+
/* }}} */
50+
#else
4051
PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
4152
{
4253
const char *ptr;
@@ -68,8 +79,8 @@ PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
6879
smart_string_free(&fbuf);
6980
smart_string_free(&sbuf);
7081
}
71-
7282
/* }}} */
83+
#endif
7384

7485
/*
7586
* Local variables:

win32/syslog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
extern void closelog(void);
7474
extern void openlog(const char *, int, int);
7575
extern void syslog(int, const char *, ...);
76+
extern void vsyslog(int, const char *, va_list ap);
7677

7778

7879
#endif /* SYSLOG_H */

win32/wsyslog.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ void closelog(void)
8080
void syslog(int priority, const char *message, ...)
8181
{
8282
va_list args;
83+
84+
va_start(args, message); /* initialize vararg mechanism */
85+
vsyslog(priority, message, args);
86+
va_end(args);
87+
}
88+
89+
void vsyslog(int priority, const char *message, va_list args)
90+
{
8391
LPTSTR strs[2];
8492
unsigned short etype;
8593
char *tmp = NULL;
@@ -102,13 +110,11 @@ void syslog(int priority, const char *message, ...)
102110
etype = EVENTLOG_WARNING_TYPE;
103111
evid = PHP_SYSLOG_WARNING_TYPE;
104112
}
105-
va_start(args, message); /* initialize vararg mechanism */
106113
vspprintf(&tmp, 0, message, args); /* build message */
107114
strs[0] = PW32G(log_header); /* write header */
108115
strs[1] = tmp; /* then the message */
109116
/* report the event */
110117
ReportEvent(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL);
111-
va_end(args);
112118
efree(tmp);
113119
}
114120

@@ -127,7 +133,6 @@ void openlog(const char *ident, int logopt, int facility)
127133
PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION);
128134
spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
129135
}
130-
131136
/*
132137
* Local variables:
133138
* tab-width: 4

0 commit comments

Comments
 (0)