mirror of
https://github.com/nextcloud/server.git
synced 2026-04-04 16:45:22 -04:00
Merge pull request #53758 from nextcloud/backport/53738/stable31
[stable31] fix(syslog): open syslog channel on write
This commit is contained in:
commit
79205dd2ff
1 changed files with 6 additions and 2 deletions
|
|
@ -20,15 +20,18 @@ class Syslog extends LogDetails implements IWriter {
|
|||
ILogger::FATAL => LOG_CRIT,
|
||||
];
|
||||
|
||||
private string $tag;
|
||||
|
||||
public function __construct(
|
||||
SystemConfig $config,
|
||||
?string $tag = null,
|
||||
) {
|
||||
parent::__construct($config);
|
||||
if ($tag === null) {
|
||||
$tag = $config->getValue('syslog_tag', 'Nextcloud');
|
||||
$this->tag = $config->getValue('syslog_tag', 'Nextcloud');
|
||||
} else {
|
||||
$this->tag = $tag;
|
||||
}
|
||||
openlog($tag, LOG_PID | LOG_CONS, LOG_USER);
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
|
@ -41,6 +44,7 @@ class Syslog extends LogDetails implements IWriter {
|
|||
*/
|
||||
public function write(string $app, $message, int $level): void {
|
||||
$syslog_level = $this->levels[$level];
|
||||
openlog($this->tag, LOG_PID | LOG_CONS, LOG_USER);
|
||||
syslog($syslog_level, $this->logDetailsAsJSON($app, $message, $level));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue