summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-08-19 13:49:45 +0200
committerAnatol Belski <ab@php.net>2017-08-19 13:51:44 +0200
commitdda70e01069af9cf833ee8a207c4083c437b8343 (patch)
treeffe689c5758a63927d64ce4b939c0cfb2ea93e79
parenta1f3a0105d885879102d366de506c353a75c8d04 (diff)
downloadphp-git-dda70e01069af9cf833ee8a207c4083c437b8343.tar.gz
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.
-rw-r--r--main/php_syslog.c13
-rw-r--r--win32/syslog.h1
-rw-r--r--win32/wsyslog.c11
3 files changed, 21 insertions, 4 deletions
diff --git a/main/php_syslog.c b/main/php_syslog.c
index c351951afe..63b23c2363 100644
--- a/main/php_syslog.c
+++ b/main/php_syslog.c
@@ -37,6 +37,17 @@
#define syslog std_syslog
#endif
+#ifdef PHP_WIN32
+PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
+{
+ va_list args;
+
+ va_start(args, format);
+ vsyslog(priority, format, args);
+ va_end(args);
+}
+/* }}} */
+#else
PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
{
const char *ptr;
@@ -68,8 +79,8 @@ PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
smart_string_free(&fbuf);
smart_string_free(&sbuf);
}
-
/* }}} */
+#endif
/*
* Local variables:
diff --git a/win32/syslog.h b/win32/syslog.h
index 104c4b75ff..3220ed66b6 100644
--- a/win32/syslog.h
+++ b/win32/syslog.h
@@ -73,6 +73,7 @@
extern void closelog(void);
extern void openlog(const char *, int, int);
extern void syslog(int, const char *, ...);
+extern void vsyslog(int, const char *, va_list ap);
#endif /* SYSLOG_H */
diff --git a/win32/wsyslog.c b/win32/wsyslog.c
index 6b0f03e8ea..b14fc1cc61 100644
--- a/win32/wsyslog.c
+++ b/win32/wsyslog.c
@@ -80,6 +80,14 @@ void closelog(void)
void syslog(int priority, const char *message, ...)
{
va_list args;
+
+ va_start(args, message); /* initialize vararg mechanism */
+ vsyslog(priority, message, args);
+ va_end(args);
+}
+
+void vsyslog(int priority, const char *message, va_list args)
+{
LPTSTR strs[2];
unsigned short etype;
char *tmp = NULL;
@@ -102,13 +110,11 @@ void syslog(int priority, const char *message, ...)
etype = EVENTLOG_WARNING_TYPE;
evid = PHP_SYSLOG_WARNING_TYPE;
}
- va_start(args, message); /* initialize vararg mechanism */
vspprintf(&tmp, 0, message, args); /* build message */
strs[0] = PW32G(log_header); /* write header */
strs[1] = tmp; /* then the message */
/* report the event */
ReportEvent(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL);
- va_end(args);
efree(tmp);
}
@@ -127,7 +133,6 @@ void openlog(const char *ident, int logopt, int facility)
PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION);
spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
}
-
/*
* Local variables:
* tab-width: 4