mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-21 12:54:26 +02:00
parent
a24999ff7f
commit
8952434393
@ -63,7 +63,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(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'logging_application',
|
'logging_application',
|
||||||
@ -71,7 +71,7 @@ class LoggingConfigForm extends Form
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
'label' => $this->translate('Application Prefix'),
|
'label' => $this->translate('Application Prefix'),
|
||||||
'description' => $this->translate(
|
'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.'),
|
'requirement' => $this->translate('The application prefix must not contain whitespace.'),
|
||||||
'value' => 'icingaweb2',
|
'value' => 'icingaweb2',
|
||||||
|
@ -5,6 +5,7 @@ namespace Icinga\Application\Logger\Writer;
|
|||||||
|
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Application\Logger\LogWriter;
|
use Icinga\Application\Logger\LogWriter;
|
||||||
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Exception\NotWritableError;
|
use Icinga\Exception\NotWritableError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,12 +15,30 @@ use Icinga\Exception\NotWritableError;
|
|||||||
*/
|
*/
|
||||||
class PhpWriter extends LogWriter
|
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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function log($severity, $message)
|
public function log($severity, $message)
|
||||||
{
|
{
|
||||||
if (! error_log(Logger::$levels[$severity] . ' - ' . str_replace("\n", ' ', $message))) {
|
if (! error_log(
|
||||||
|
$this->ident . ': ' . Logger::$levels[$severity] . ' - ' . str_replace("\n", ' ', $message)
|
||||||
|
)) {
|
||||||
throw new NotWritableError('Could not log to ' . (ini_get('error_log') ?: 'SAPI'));
|
throw new NotWritableError('Could not log to ' . (ini_get('error_log') ?: 'SAPI'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user