Merge pull request #53758 from nextcloud/backport/53738/stable31

[stable31] fix(syslog): open syslog channel on write
This commit is contained in:
Kate 2025-07-03 08:17:19 +02:00 committed by GitHub
commit 79205dd2ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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));
}
}