|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-22 18:57 UTC] sylvain at abstraction dot fr
Description:
------------
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 we aim to use syslog with different log locals.
Expected result:
----------------
$syslog_local0 = openlog('foo', LOG_NDELAY, LOG_LOCAL0);
syslog($syslog_local0, LOG_WARNING, "blah");
$syslog_local1 = openlog('bar', LOG_NDELAY, LOG_LOCAL1);
syslog($syslog_local1, LOG_WARNING, "blah blah");
closelog($syslog_local0);
closelog($syslog_local1);
Patchesphp-syslog.v4.patch.txt (last revision 2011-07-05 13:31 UTC by fat@php.net)php-syslog.patch (last revision 2011-01-30 13:31 UTC by fat@php.net) php_syslog_multiple_context.patch (last revision 2011-01-29 13:02 UTC by fat@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 07:00:02 2025 UTC |
I just attached a patch which should do the trick. I don't know if it'll be accepted by the dev team who handle this part of PHP. openlog() returns a ressource instead of a bool. closelog() and syslog() have now a last and optional parameter: a context ressource. Everything which was working before, should still work. The only change is the return value of openlog() which should be strictely compared (openlog(...) !== true). here is a sample test script: <?php syslog(LOG_ERR, "test 1 on ressource #0"); // Jul 23 05:20:22 wild php: test 1 on ressource #0 $r1 = openlog("test syslog #1", LOG_PID, LOG_SYSLOG); $r2 = openlog("test syslog #2", LOG_PID, LOG_SYSLOG); syslog(LOG_ERR, "test on ressource #1", $r1); // Jul 23 05:20:22 wild test syslog #1[24144]: test on ressource #1 syslog(LOG_ERR, "test on ressource #2", $r2); // Jul 23 05:20:22 wild test syslog #2[24144]: test on ressource #2 closelog($r1); closelog($r2); syslog(LOG_ERR, "test 2 on ressource #0"); // Jul 23 05:20:22 wild php[24144]: test 2 on ressource #0 openlog("test syslog #0", LOG_PID, LOG_SYSLOG); syslog(LOG_ERR, "test 3 on ressource #0"); // Jul 23 05:20:22 wild test syslog #0[24144]: test 3 on ressource #0 closelog(); syslog(LOG_ERR, "test 4 on ressource #0"); // Jul 23 05:20:22 wild php[24144]: test 4 on ressource #0 ?>