+
+ private function customErrorHandler($code, $msg)
+ {
+ $this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg);
+ }
+
+ /**
+ * A syslog wrapper to make syslog functionality testable
+ *
+ * @param int $level The syslog priority
+ * @param string $entry The message to send to the syslog function
+ */
+ protected function syslogWrapper($level, $entry)
+ {
+ set_error_handler([$this, 'customErrorHandler']);
+ $written = syslog($level, $entry);
+ restore_error_handler();
+
+ if (!$written) {
+ throw new \UnexpectedValueException(sprintf('Can\'t write into syslog for ident "%s" and facility "%s": ' . $this->errorMessage, $this->channel, $this->logFacility));
+ }
+ }