Skip to content

Commit

Permalink
Allow passing of openlog() options in SyslogHandler ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
dzuelke committed Aug 29, 2012
1 parent 75af99d commit 76fb21b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Monolog/Handler/SyslogHandler.php
Expand Up @@ -67,7 +67,7 @@ class SyslogHandler extends AbstractProcessingHandler
* @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
*/
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);

Expand All @@ -89,7 +89,7 @@ public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG
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.'"');
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Monolog/Handler/SyslogHandlerTest.php
Expand Up @@ -10,6 +10,7 @@
*/

namespace Monolog\Handler;
use Monolog\Logger;

class SyslogHandlerTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -26,6 +27,9 @@ public function testConstruct()

$handler = new SyslogHandler('test', 'user');
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);

$handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR);
$this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler);
}

/**
Expand Down

0 comments on commit 76fb21b

Please sign in to comment.