Skip to content

Commit b564398

Browse files
Merge pull request #53757 from nextcloud/backport/53738/stable30
[stable30] fix(syslog): open syslog channel on write
2 parents b98ca97 + af5e411 commit b564398

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/private/Log/Syslog.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ class Syslog extends LogDetails implements IWriter {
2020
ILogger::FATAL => LOG_CRIT,
2121
];
2222

23+
private string $tag;
24+
2325
public function __construct(
2426
SystemConfig $config,
2527
?string $tag = null,
2628
) {
2729
parent::__construct($config);
2830
if ($tag === null) {
29-
$tag = $config->getValue('syslog_tag', 'Nextcloud');
31+
$this->tag = $config->getValue('syslog_tag', 'Nextcloud');
32+
} else {
33+
$this->tag = $tag;
3034
}
31-
openlog($tag, LOG_PID | LOG_CONS, LOG_USER);
3235
}
3336

3437
public function __destruct() {
@@ -41,6 +44,7 @@ public function __destruct() {
4144
*/
4245
public function write(string $app, $message, int $level): void {
4346
$syslog_level = $this->levels[$level];
47+
openlog($this->tag, LOG_PID | LOG_CONS, LOG_USER);
4448
syslog($syslog_level, $this->logDetailsAsJSON($app, $message, $level));
4549
}
4650
}

0 commit comments

Comments
 (0)