From 12f12f2d4ca830e2b5fb6f2b675b209863d1b8ae Mon Sep 17 00:00:00 2001 From: davewwww Date: Thu, 2 May 2013 19:32:35 +0300 Subject: [PATCH] Update SyslogHandler.php move openlog() to write() method to use multiple facilities. --- src/Monolog/Handler/SyslogHandler.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Monolog/Handler/SyslogHandler.php b/src/Monolog/Handler/SyslogHandler.php index c4856cf7..a9f12b72 100644 --- a/src/Monolog/Handler/SyslogHandler.php +++ b/src/Monolog/Handler/SyslogHandler.php @@ -89,9 +89,9 @@ class SyslogHandler extends AbstractProcessingHandler throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given'); } - if (!openlog($ident, $logopts, $facility)) { - throw new \LogicException('Can\'t open syslog for ident "'.$ident.'" and facility "'.$facility.'"'); - } + $this->ident = $ident; + $this->logopts = $logopts; + $this->facility = $facility; } /** @@ -107,7 +107,10 @@ class SyslogHandler extends AbstractProcessingHandler */ protected function write(array $record) { - syslog($this->logLevels[$record['level']], (string) $record['formatted']); + if (!openlog($this->ident, $this->logopts, $this->facility)) { + throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"'); + } + syslog($this->logLevels[$record['level']], (string)$record['formatted']); } /**