/**
* Translates LogLevel log levels to syslog log priorities.
- * @var array
+ * @var array<string,int>
*/
public const logLevels = [
LogLevel::DEBUG => LOG_DEBUG,
/**
* Indicates what logging options will be used when generating a log message
* @see http://php.net/manual/en/function.openlog.php#refsect1-function.openlog-parameters
- *
- * @var int
*/
- private $logOpts;
+ private int $logOpts;
/**
* Used to specify what type of program is logging the message
* @see http://php.net/manual/en/function.openlog.php#refsect1-function.openlog-parameters
- *
- * @var int
*/
- private $logFacility;
+ private int $logFacility;
/**
* The minimum loglevel at which this logger will be triggered
- * @var int
*/
- private $logLevel;
+ private int $logLevel;
/**
* A error message of the current operation
- * @var string
*/
- private $errorMessage;
+ private string $errorMessage;
/**
* {@inheritdoc}
*
- * @param string $logLevel The minimum loglevel at which this logger will be triggered
- * @param string $logOptions
- * @param string $logFacility
+ * @param int $logLevel The minimum loglevel at which this logger will be triggered
+ * @param int $logOptions
+ * @param int $logFacility
*/
- public function __construct(string $channel, IHaveCallIntrospections $introspection, string $logLevel, string $logOptions, string $logFacility)
+ public function __construct(string $channel, IHaveCallIntrospections $introspection, int $logLevel, int $logOptions, int $logFacility)
{
parent::__construct($channel, $introspection);
restore_error_handler();
if (!$opened) {
- throw new LoggerException(sprintf('Can\'t open syslog for ident "%s" and facility "%s": ' . $this->errorMessage, $this->channel, $this->logFacility));
+ throw new LoggerException(sprintf('Can\'t open syslog for ident "%s" and facility "%s": ' . $this->errorMessage, $this->channel, (string) $this->logFacility));
}
$this->syslogWrapper($priority, $message);
restore_error_handler();
if (!$written) {
- throw new LoggerException(sprintf('Can\'t write into syslog for ident "%s" and facility "%s": ' . $this->errorMessage, $this->channel, $this->logFacility));
+ throw new LoggerException(sprintf('Can\'t write into syslog for ident "%s" and facility "%s": ' . $this->errorMessage, $this->channel, (string) $this->logFacility));
}
}
}
{
public function create(IManageConfigValues $config): LoggerInterface
{
- $logOpts = $config->get('system', 'syslog_flags') ?? SyslogLoggerClass::DEFAULT_FLAGS;
- $logFacility = $config->get('system', 'syslog_facility') ?? SyslogLoggerClass::DEFAULT_FACILITY;
+ $logOpts = (int) $config->get('system', 'syslog_flags') ?? SyslogLoggerClass::DEFAULT_FLAGS;
+ $logFacility = (int) $config->get('system', 'syslog_facility') ?? SyslogLoggerClass::DEFAULT_FACILITY;
$loglevel = SyslogLogger::mapLegacyConfigDebugLevel($config->get('system', 'loglevel'));
- if (array_key_exists($loglevel, SyslogLoggerClass::logLevels)) {
- $loglevel = SyslogLoggerClass::logLevels[$loglevel];
- } else {
+ if (!array_key_exists($loglevel, SyslogLoggerClass::logLevels)) {
throw new LogLevelException(sprintf('The level "%s" is not valid.', $loglevel));
}
+ $loglevel = SyslogLoggerClass::logLevels[$loglevel];
+
return new SyslogLoggerWrapper($this->channel, $this->introspection, $loglevel, $logOpts, $logFacility);
}
}
{
private $content;
- public function __construct(string $channel, IHaveCallIntrospections $introspection, string $logLevel, string $logOptions, string $logFacility)
+ public function __construct(string $channel, IHaveCallIntrospections $introspection, int $logLevel, int $logOptions, int $logFacility)
{
parent::__construct($channel, $introspection, $logLevel, $logOptions, $logFacility);