@ -20,15 +20,18 @@ class Syslog extends LogDetails implements IWriter {
ILogger::FATAL => LOG_CRIT,
ILogger::FATAL => LOG_CRIT,
];
];
private string $tag;
public function __construct(
public function __construct(
SystemConfig $config,
SystemConfig $config,
?string $tag = null,
?string $tag = null,
) {
) {
parent::__construct($config);
parent::__construct($config);
if ($tag === null) {
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() {
public function __destruct() {
@ -41,6 +44,7 @@ class Syslog extends LogDetails implements IWriter {
*/
*/
public function write(string $app, $message, int $level): void {
public function write(string $app, $message, int $level): void {
$syslog_level = $this->levels[$level];
$syslog_level = $this->levels[$level];
openlog($this->tag, LOG_PID | LOG_CONS, LOG_USER);
syslog($syslog_level, $this->logDetailsAsJSON($app, $message, $level));
syslog($syslog_level, $this->logDetailsAsJSON($app, $message, $level));
}
}
}
}