Req #51118 [PATCH]: Allow multiple simultaneous syslog connections
| From: | fat@php.net | Date: | Sat, 29 Jan 2011 13:02:29 +0000 |
| Subject: | Req #51118 [PATCH]: Allow multiple simultaneous syslog connections | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158314@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51118&edit=1
ID: 51118
Patch added by: fat@php.net
Reported by: sylvain at abstraction dot fr
Summary: Allow multiple simultaneous syslog connections
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: all
PHP Version: 5.2.12
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: php_syslog_multiple_context.patch
Revision: 1296306149
URL:
http://bugs.php.net/patch-display.php?bug=51118&patch=php_syslog_multiple_context.patch&revision=1296306149
Previous Comments:
------------------------------------------------------------------------
[2010-07-23 13:11:41] sylvain at abstraction dot fr
Thank you very much for your time.
Hope it will be accepted in trunk.
Regards.
------------------------------------------------------------------------
[2010-07-23 05:30:28] fat@php.net
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
?>
------------------------------------------------------------------------
[2010-07-23 05:23:41] fat@php.net
The following patch has been added/updated:
Patch Name: php_syslog_multiple_context.patch
Revision: 1279855421
URL:
http://bugs.php.net/patch-display.php?bug=51118&patch=php_syslog_multiple_context.patch&revision=1279855421
------------------------------------------------------------------------
[2010-02-22 18:57:36] 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);
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51118&edit=1