mirror of
https://github.com/friendica/friendica
synced 2025-04-27 15:50:12 +00:00
cleanup sysloglogger
This commit is contained in:
parent
25b6db6aca
commit
22f1983cc0
5 changed files with 56 additions and 44 deletions
|
@ -85,6 +85,27 @@ class SyslogLogger extends AbstractFriendicaLogger
|
|||
$this->introspection->addClasses(array(self::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new entry to the syslog
|
||||
*
|
||||
* @param int $level
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @throws InternalServerErrorException if the syslog isn't available
|
||||
*/
|
||||
protected function addEntry($level, $message, $context = [])
|
||||
{
|
||||
$logLevel = $this->mapLevelToPriority($level);
|
||||
|
||||
if ($logLevel >= $this->logLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
$formattedLog = $this->formatLog($logLevel, $message, $context);
|
||||
$this->write($logLevel, $formattedLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the LogLevel (@see LogLevel ) to a SysLog priority (@see http://php.net/manual/en/function.syslog.php#refsect1-function.syslog-parameters )
|
||||
*
|
||||
|
@ -103,6 +124,14 @@ class SyslogLogger extends AbstractFriendicaLogger
|
|||
return $this->logLevels[$level];
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Syslog
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
closelog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a message to the syslog
|
||||
* @see http://php.net/manual/en/function.syslog.php#refsect1-function.syslog-parameters
|
||||
|
@ -121,14 +150,6 @@ class SyslogLogger extends AbstractFriendicaLogger
|
|||
syslog($priority, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the Syslog
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
closelog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a log record for the syslog output
|
||||
*
|
||||
|
@ -152,25 +173,4 @@ class SyslogLogger extends AbstractFriendicaLogger
|
|||
|
||||
return $logMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new entry to the syslog
|
||||
*
|
||||
* @param int $level
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @throws InternalServerErrorException if the syslog isn't available
|
||||
*/
|
||||
protected function addEntry($level, $message, $context = [])
|
||||
{
|
||||
$logLevel = $this->mapLevelToPriority($level);
|
||||
|
||||
if ($logLevel >= $this->logLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
$formattedLog = $this->formatLog($level, $message, $context);
|
||||
$this->write($level, $formattedLog);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue