com php-src: Follow up on ed9c16ad5def47d1c8ae2787f53dccfac893ce5f: main/php_syslog.c win32/syslog.h win32/wsyslo g.c
| From: | Anatol Belski | Date: | Sat, 19 Aug 2017 11:51:44 +0000 |
| Subject: | com php-src: Follow up on ed9c16ad5def47d1c8ae2787f53dccfac893ce5f: main/php_syslog.c win32/syslog.h win32/wsyslo g.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99104@lists.php.net to get a copy of this message | ||
Commit: dda70e01069af9cf833ee8a207c4083c437b8343
Author: Anatol Belski <ab@php.net> Sat, 19 Aug 2017 13:49:45 +0200
Parents: a1f3a0105d885879102d366de506c353a75c8d04
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dda70e01069af9cf833ee8a207c4083c437b8343
Log:
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.
Changed paths:
M main/php_syslog.c
M win32/syslog.h
M win32/wsyslog.c
Diff:
diff --git a/main/php_syslog.c b/main/php_syslog.c
index c351951..63b23c2 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 104c4b7..3220ed6 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 6b0f03e..b14fc1c 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