This patch allows users to use multiple simultaneous syslog connections.
Currently, the openlog function does not return a resource like would do the fopen or any database connection function. That implementation limits to 1 the simultaneous number of connections possible to syslog and this is problematic when the goal is to use syslog with different log locals.
The patch changes openlog, syslog and closelog to handle a ressource which contain ident, option and facility.
The proposed implementation should not break any current usage of syslog functions. Here is the changes :
<?php syslog(LOG_ERR, "test 1 wihout calling openlog"); /* ident is default aka "php" Jul 23 05:20:22 hostname php: test 1 wihout calling openlog */ $r1 = openlog("ident#1", LOG_PID, LOG_SYSLOG); $r2 = openlog("ident#2", LOG_PID, LOG_SYSLOG); syslog(LOG_ERR, "test on #1", $r1); /* use $r1, so ident is now "ident#1" Jul 23 05:20:22 hostname ident#1[24144]: test on #1 */ syslog(LOG_ERR, "test on ressource #2", $r2); /* use $r2, so ident is now "ident#2" Jul 23 05:20:22 hostname ident#2[24144]: test on #2 */ closelog($r1); closelog($r2); syslog(LOG_ERR, "test 2 without openlog"); /* as $r1 and $r2 have been closed, ident has been reset to default aka "php" Jul 23 05:20:22 hostname php: test 2 wihout calling openlog */ openlog("ident#0", LOG_PID, LOG_SYSLOG); syslog(LOG_ERR, "test 3 with openlog() but without ressource"); /* openlog has been called, so ident not the default until closelog() call Jul 23 05:20:22 hostname php[24144]: test 3 with openlog() but without ressource */ closelog(); syslog(LOG_ERR, "test 4 without calling openlog"); /* closelog() has been called, ident has been reset to default aka "php" Jul 23 05:20:22 hostname php: test 4 wihout calling openlog */ ?>