1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-19 11:21:27 +02:00

Merge pull request #109 from dzuelke/openlog

Allow passing of openlog() options in SyslogHandler ctor
This commit is contained in:
Jordi Boggiano
2012-08-29 04:25:58 -07:00
2 changed files with 7 additions and 2 deletions

View File

@@ -66,8 +66,9 @@ class SyslogHandler extends AbstractProcessingHandler
* @param mixed $facility * @param mixed $facility
* @param integer $level The minimum logging level at which this handler will be triggered * @param integer $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
* @param int $logopts Option flags for the openlog() call, defaults to LOG_PID
*/ */
public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID)
{ {
parent::__construct($level, $bubble); parent::__construct($level, $bubble);
@@ -89,7 +90,7 @@ class SyslogHandler extends AbstractProcessingHandler
throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given'); throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
} }
if (!openlog($ident, LOG_PID, $facility)) { if (!openlog($ident, $logopts, $facility)) {
throw new \LogicException('Can\'t open syslog for ident "'.$ident.'" and facility "'.$facility.'"'); throw new \LogicException('Can\'t open syslog for ident "'.$ident.'" and facility "'.$facility.'"');
} }
} }

View File

@@ -10,6 +10,7 @@
*/ */
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Logger;
class SyslogHandlerTest extends \PHPUnit_Framework_TestCase class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
{ {
@@ -26,6 +27,9 @@ class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
$handler = new SyslogHandler('test', 'user'); $handler = new SyslogHandler('test', 'user');
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
$handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
} }
/** /**