ZF-7603: Syslog writer facility should be long
Description
In Zend_Log_Writer_Syslog::facility is defined as string and it is sent to openlog() this way hence openlog()'s 3rd parameter should be long, choosen from the predefined PHP constans LOG*. I would recommend to use the string with constant($this->_facility) and document that user should specify the constant name to use if required.
So the patch:
protected function _initializeSyslog()
{
self::$_lastApplication = $this->_application;
self::$_lastFacility = $this->_facility;
openlog($this->_application, LOG_PID, cnstant($this->_facility));
}
Comments
Posted by Péter Nagy (antronin) on 2009-08-16T03:40:48.000+0000
I made a typo in the code above ("cnstant" is "constant"). The last line should be:
Posted by Matthew Weier O'Phinney (matthew) on 2010-06-18T09:17:00.000+0000
Actually, by default, the $_facility parameter is defined to the value of the LOG_USER constant; it's not actually a string, though the docblock reports it as such. You can alter the facility using a setter, but the assumption is that you're passing in one of those constants.
I think one of two things need to happen: * The $facility property needs to be marked as an integer * setFacility() needs to check the value against the known LOG* constants.
I'll proceed with those changes.
Posted by Matthew Weier O'Phinney (matthew) on 2010-06-18T09:26:21.000+0000
Updated per my comment in both trunk and 1.10 release branch.
Posted by Ramon Henrique Ornelas (ramon) on 2010-06-18T17:21:10.000+0000
Correction called function in_array() r22459 merged in branch r22460.
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-06-18T17:26:45.000+0000
Unittests missing
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-06-18T18:20:42.000+0000
Closing again since there's been a separate issue added for the tests (ZF-10015).
Posted by Ramon Henrique Ornelas (ramon) on 2010-06-19T13:52:54.000+0000
Problem r22450 some constants not exists in windows generate notices.
Constants what may not exists depending do system operational: LOG_AUTHPRIV, LOG_CRON, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7, LOG_NEWS, LOG_SYSLOG, LOG_UUCP.
See define_syslog_variables section Return Values
Posted by Ramon Henrique Ornelas (ramon) on 2010-06-19T15:23:35.000+0000
Resolved problem notices in patch.
In patch added Zend_Log_Writer_Syslog::_initializeValidFacilities()
If Zend_Log_Writer_Syslog::_initializeValidFacilities() called in the Zend_Log_Writer_Syslog::__construct() could cause break BC.
Example:
Posted by Matthew Weier O'Phinney (matthew) on 2010-06-21T05:16:32.000+0000
I made one minor change to the patch, and that was to do the detection of the validFacilities array size within the setFacility() method. This reduces the number of function calls necessary for applications where the facility may be changed multiple times.
Patch applied to trunk and 1.10 release branch.
Posted by Ramon Henrique Ornelas (ramon) on 2010-06-21T06:00:24.000+0000
Matthew
Amendment perfect
Thanks ;).