Merge branch 'feature/emit-log-messages-in-the-webserver-s-log-11652'
resolves #11652
This commit is contained in:
commit
f27e8c059d
|
@ -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',
|
||||
|
|
Binary file not shown.
|
@ -2979,6 +2979,11 @@ msgctxt "app.config.logging.level"
|
|||
msgid "Warning"
|
||||
msgstr "Warnung"
|
||||
|
||||
#: /vagrant/application/forms/Config/General/LoggingConfigForm.php:40
|
||||
msgctxt "app.config.logging.type"
|
||||
msgid "Webserver Log"
|
||||
msgstr "Webserver-Log"
|
||||
|
||||
#: /vagrant/application/views/scripts/authentication/login.phtml:5
|
||||
msgid ""
|
||||
"Welcome to Icinga Web 2. For users of the screen reader Jaws full and "
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Application\Logger\Writer;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Application\Logger\LogWriter;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\NotWritableError;
|
||||
|
||||
/**
|
||||
* Log to the webserver log, a file or syslog
|
||||
*
|
||||
* @see https://secure.php.net/manual/en/errorfunc.configuration.php#ini.error-log
|
||||
*/
|
||||
class PhpWriter extends LogWriter
|
||||
{
|
||||
/**
|
||||
* Prefix to prepend to each message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ident;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __construct(ConfigObject $config)
|
||||
{
|
||||
parent::__construct($config);
|
||||
$this->ident = $config->get('application', 'icingaweb2');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($severity, $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'));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -70,12 +70,24 @@ class GeneralConfigStep extends Step
|
|||
$loggingHtml = '<p>' . mt('setup', 'Logging will be disabled.') . '</p>';
|
||||
} else {
|
||||
$level = $this->data['generalConfig']['logging_level'];
|
||||
switch ($type) {
|
||||
case 'syslog':
|
||||
$typeText = t('Syslog', 'app.config.logging.type');
|
||||
break;
|
||||
case 'php':
|
||||
$typeText = t('Webserver Log', 'app.config.logging.type');
|
||||
break;
|
||||
case 'file':
|
||||
$typeText = t('File', 'app.config.logging.type');
|
||||
break;
|
||||
}
|
||||
|
||||
$loggingHtml = ''
|
||||
. '<table>'
|
||||
. '<tbody>'
|
||||
. '<tr>'
|
||||
. '<td><strong>' . t('Type', 'app.config.logging') . '</strong></td>'
|
||||
. '<td>' . ($type === 'syslog' ? 'Syslog' : t('File', 'app.config.logging.type')) . '</td>'
|
||||
. '<td>' . $typeText . '</td>'
|
||||
. '</tr>'
|
||||
. '<tr>'
|
||||
. '<td><strong>' . t('Level', 'app.config.logging') . '</strong></td>'
|
||||
|
@ -88,7 +100,7 @@ class GeneralConfigStep extends Step
|
|||
)) . '</td>'
|
||||
. '</tr>'
|
||||
. '<tr>'
|
||||
. ($type === 'syslog' ? (
|
||||
. ($type !== 'file' ? (
|
||||
'<td><strong>' . t('Application Prefix') . '</strong></td>'
|
||||
. '<td>' . $this->data['generalConfig']['logging_application'] . '</td>'
|
||||
) : (
|
||||
|
|
Loading…
Reference in New Issue