@@ -12,39 +12,39 @@ |
||
12 | 12 | use OCP\Log\IWriter; |
13 | 13 | |
14 | 14 | class Syslog extends LogDetails implements IWriter { |
15 | - protected array $levels = [ |
|
16 | - ILogger::DEBUG => LOG_DEBUG, |
|
17 | - ILogger::INFO => LOG_INFO, |
|
18 | - ILogger::WARN => LOG_WARNING, |
|
19 | - ILogger::ERROR => LOG_ERR, |
|
20 | - ILogger::FATAL => LOG_CRIT, |
|
21 | - ]; |
|
15 | + protected array $levels = [ |
|
16 | + ILogger::DEBUG => LOG_DEBUG, |
|
17 | + ILogger::INFO => LOG_INFO, |
|
18 | + ILogger::WARN => LOG_WARNING, |
|
19 | + ILogger::ERROR => LOG_ERR, |
|
20 | + ILogger::FATAL => LOG_CRIT, |
|
21 | + ]; |
|
22 | 22 | |
23 | - private string $tag; |
|
23 | + private string $tag; |
|
24 | 24 | |
25 | - public function __construct( |
|
26 | - SystemConfig $config, |
|
27 | - ?string $tag = null, |
|
28 | - ) { |
|
29 | - parent::__construct($config); |
|
30 | - if ($tag === null) { |
|
31 | - $this->tag = $config->getValue('syslog_tag', 'Nextcloud'); |
|
32 | - } else { |
|
33 | - $this->tag = $tag; |
|
34 | - } |
|
35 | - } |
|
25 | + public function __construct( |
|
26 | + SystemConfig $config, |
|
27 | + ?string $tag = null, |
|
28 | + ) { |
|
29 | + parent::__construct($config); |
|
30 | + if ($tag === null) { |
|
31 | + $this->tag = $config->getValue('syslog_tag', 'Nextcloud'); |
|
32 | + } else { |
|
33 | + $this->tag = $tag; |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | - public function __destruct() { |
|
38 | - closelog(); |
|
39 | - } |
|
37 | + public function __destruct() { |
|
38 | + closelog(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * write a message in the log |
|
43 | - * @param string|array $message |
|
44 | - */ |
|
45 | - public function write(string $app, $message, int $level): void { |
|
46 | - $syslog_level = $this->levels[$level]; |
|
47 | - openlog($this->tag, LOG_PID | LOG_CONS, LOG_USER); |
|
48 | - syslog($syslog_level, $this->logDetailsAsJSON($app, $message, $level)); |
|
49 | - } |
|
41 | + /** |
|
42 | + * write a message in the log |
|
43 | + * @param string|array $message |
|
44 | + */ |
|
45 | + public function write(string $app, $message, int $level): void { |
|
46 | + $syslog_level = $this->levels[$level]; |
|
47 | + openlog($this->tag, LOG_PID | LOG_CONS, LOG_USER); |
|
48 | + syslog($syslog_level, $this->logDetailsAsJSON($app, $message, $level)); |
|
49 | + } |
|
50 | 50 | } |