mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
00880710ed
commit
52e6293b96
@ -4,6 +4,7 @@
|
|||||||
namespace Icinga\Forms\Config\General;
|
namespace Icinga\Forms\Config\General;
|
||||||
|
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
|
use Icinga\Application\Platform;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,22 +91,50 @@ class LoggingConfigForm extends Form
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
* Note(el): Since we provide only one possible value for the syslog facility, I opt against exposing
|
if (Platform::isWindows()) {
|
||||||
* this configuration.
|
/* @see https://secure.php.net/manual/en/function.openlog.php */
|
||||||
*/
|
$this->addElement(
|
||||||
// $this->addElement(
|
'hidden',
|
||||||
// 'select',
|
'logging_facility',
|
||||||
// 'logging_facility',
|
array(
|
||||||
// array(
|
'value' => 'user',
|
||||||
// 'required' => true,
|
'disabled' => true
|
||||||
// 'label' => $this->translate('Facility'),
|
)
|
||||||
// 'description' => $this->translate('The syslog facility to utilize.'),
|
);
|
||||||
// 'multiOptions' => array(
|
} else {
|
||||||
// 'user' => 'LOG_USER'
|
$this->addElement(
|
||||||
// )
|
'select',
|
||||||
// )
|
'logging_facility',
|
||||||
// );
|
array(
|
||||||
|
'required' => true,
|
||||||
|
'label' => $this->translate('Facility'),
|
||||||
|
'description' => $this->translate('The syslog facility to utilize.'),
|
||||||
|
'value' => 'user',
|
||||||
|
'multiOptions' => array(
|
||||||
|
'auth' => 'LOG_AUTH',
|
||||||
|
'authpriv' => 'LOG_AUTHPRIV',
|
||||||
|
'cron' => 'LOG_CRON',
|
||||||
|
'daemon' => 'LOG_DAEMON',
|
||||||
|
'kern' => 'LOG_KERN',
|
||||||
|
'local0' => 'LOG_LOCAL0',
|
||||||
|
'local1' => 'LOG_LOCAL1',
|
||||||
|
'local2' => 'LOG_LOCAL2',
|
||||||
|
'local3' => 'LOG_LOCAL3',
|
||||||
|
'local4' => 'LOG_LOCAL4',
|
||||||
|
'local5' => 'LOG_LOCAL5',
|
||||||
|
'local6' => 'LOG_LOCAL6',
|
||||||
|
'local7' => 'LOG_LOCAL7',
|
||||||
|
'lpr' => 'LOG_LPR',
|
||||||
|
'mail' => 'LOG_MAIL',
|
||||||
|
'news' => 'LOG_NEWS',
|
||||||
|
'syslog' => 'LOG_SYSLOG',
|
||||||
|
'user' => 'LOG_USER',
|
||||||
|
'uucp' => 'LOG_UUCP'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
} elseif (isset($formData['logging_log']) && $formData['logging_log'] === 'file') {
|
} elseif (isset($formData['logging_log']) && $formData['logging_log'] === 'file') {
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
|
@ -6,6 +6,7 @@ namespace Icinga\Application\Logger\Writer;
|
|||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use Icinga\Application\Logger\LogWriter;
|
use Icinga\Application\Logger\LogWriter;
|
||||||
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log to the syslog service
|
* Log to the syslog service
|
||||||
@ -32,7 +33,25 @@ class SyslogWriter extends LogWriter
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $facilities = array(
|
public static $facilities = array(
|
||||||
'user' => LOG_USER
|
'auth' => LOG_AUTH,
|
||||||
|
'authpriv' => LOG_AUTHPRIV,
|
||||||
|
'cron' => LOG_CRON,
|
||||||
|
'daemon' => LOG_DAEMON,
|
||||||
|
'kern' => LOG_KERN,
|
||||||
|
'local0' => LOG_LOCAL0,
|
||||||
|
'local1' => LOG_LOCAL1,
|
||||||
|
'local2' => LOG_LOCAL2,
|
||||||
|
'local3' => LOG_LOCAL3,
|
||||||
|
'local4' => LOG_LOCAL4,
|
||||||
|
'local5' => LOG_LOCAL5,
|
||||||
|
'local6' => LOG_LOCAL6,
|
||||||
|
'local7' => LOG_LOCAL7,
|
||||||
|
'lpr' => LOG_LPR,
|
||||||
|
'mail' => LOG_MAIL,
|
||||||
|
'news' => LOG_NEWS,
|
||||||
|
'syslog' => LOG_SYSLOG,
|
||||||
|
'user' => LOG_USER,
|
||||||
|
'uucp' => LOG_UUCP
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +74,16 @@ class SyslogWriter extends LogWriter
|
|||||||
public function __construct(ConfigObject $config)
|
public function __construct(ConfigObject $config)
|
||||||
{
|
{
|
||||||
$this->ident = $config->get('application', 'icingaweb2');
|
$this->ident = $config->get('application', 'icingaweb2');
|
||||||
$this->facility = static::$facilities['user'];
|
|
||||||
|
$configuredFacility = $config->get('facility', 'user');
|
||||||
|
if (! isset(static::$facilities[$configuredFacility])) {
|
||||||
|
throw new ConfigurationError(
|
||||||
|
'Invalid logging facility: "%s" (expected one of: %s)',
|
||||||
|
$configuredFacility,
|
||||||
|
implode(', ', array_keys(static::$facilities))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->facility = static::$facilities[$configuredFacility];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user