[icinga-checkins] icinga.org: icingaweb2/feature/ emit-log-messages-in-the-webserver-s-log-11652: PhpWriter: replace newlines in the message only if PHP logs to Syslog

git at icinga.org git at icinga.org
Thu Nov 3 14:11:38 CET 2016


Module: icingaweb2
Branch: feature/emit-log-messages-in-the-webserver-s-log-11652
Commit: a85d259b0afc3a1fb25f27fb12b2b972fe7d5843
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=a85d259b0afc3a1fb25f27fb12b2b972fe7d5843

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Thu Nov  3 14:06:02 2016 +0100

PhpWriter: replace newlines in the message only if PHP logs to Syslog

refs #11652

---

 library/Icinga/Application/Logger/Writer/PhpWriter.php |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/library/Icinga/Application/Logger/Writer/PhpWriter.php b/library/Icinga/Application/Logger/Writer/PhpWriter.php
index 913ea07..310cd76 100644
--- a/library/Icinga/Application/Logger/Writer/PhpWriter.php
+++ b/library/Icinga/Application/Logger/Writer/PhpWriter.php
@@ -36,9 +36,9 @@ class PhpWriter extends LogWriter
      */
     public function log($severity, $message)
     {
-        if (! error_log(
-            $this->ident . ': ' . Logger::$levels[$severity] . ' - ' . str_replace("\n", '    ', $message)
-        )) {
+        if (! error_log($this->ident . ': ' . Logger::$levels[$severity] . ' - ' . (
+            ini_get('error_log') === 'syslog' ? str_replace("\n", '    ', $message) : $message
+        ))) {
             throw new NotWritableError('Could not log to ' . (ini_get('error_log') ?: 'SAPI'));
         }
     }



More information about the icinga-checkins mailing list