From b2ab99fd7123e368a70e176668d1e89677591194 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 19 Oct 2016 15:29:51 +0200 Subject: [PATCH 1/2] Add log writer PhpWriter refs #11652 --- .../Application/Logger/Writer/PhpWriter.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 library/Icinga/Application/Logger/Writer/PhpWriter.php diff --git a/library/Icinga/Application/Logger/Writer/PhpWriter.php b/library/Icinga/Application/Logger/Writer/PhpWriter.php new file mode 100644 index 000000000..dedb2bddb --- /dev/null +++ b/library/Icinga/Application/Logger/Writer/PhpWriter.php @@ -0,0 +1,39 @@ +ident = $config->get('application', 'icingaweb2'); + } + + public function log($severity, $message) + { + if (ini_get('error_log') === 'syslog') { + $message = str_replace("\n", ' ', $message); + } + + error_log($this->ident . ': ' . Logger::$levels[$severity] . ' - ' . $message); + } +} From 707f0435a2d56dc008adb838bb5ef43ee5676c70 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 19 Oct 2016 15:34:57 +0200 Subject: [PATCH 2/2] LoggingConfigForm: make the webserver log option available refs #11652 --- application/forms/Config/General/LoggingConfigForm.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 75b82a330..e1b0e130f 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -39,6 +39,7 @@ class LoggingConfigForm extends Form 'label' => $this->translate('Logging Type'), 'description' => $this->translate('The type of logging to utilize.'), 'multiOptions' => array( + 'php' => $this->translate('Webserver Log', 'app.config.logging.type'), 'syslog' => 'Syslog', 'file' => $this->translate('File', 'app.config.logging.type'), 'none' => $this->translate('None', 'app.config.logging.type') @@ -64,7 +65,7 @@ class LoggingConfigForm extends Form ); } - if (false === isset($formData['logging_log']) || $formData['logging_log'] === 'syslog') { + if (false === isset($formData['logging_log']) || in_array($formData['logging_log'], array('syslog', 'php'))) { $this->addElement( 'text', 'logging_application', @@ -72,7 +73,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => $this->translate('Application Prefix'), 'description' => $this->translate( - 'The name of the application by which to prefix syslog messages.' + 'The name of the application by which to prefix log messages.' ), 'requirement' => $this->translate('The application prefix must not contain whitespace.'), 'value' => 'icingaweb2',