@@ -43,37 +43,37 @@ |
||
| 43 | 43 | // Syslog compatibility fields |
| 44 | 44 | |
| 45 | 45 | class Systemdlog implements IWriter { |
| 46 | - protected $levels = [ |
|
| 47 | - ILogger::DEBUG => 7, |
|
| 48 | - ILogger::INFO => 6, |
|
| 49 | - ILogger::WARN => 4, |
|
| 50 | - ILogger::ERROR => 3, |
|
| 51 | - ILogger::FATAL => 2, |
|
| 52 | - ]; |
|
| 46 | + protected $levels = [ |
|
| 47 | + ILogger::DEBUG => 7, |
|
| 48 | + ILogger::INFO => 6, |
|
| 49 | + ILogger::WARN => 4, |
|
| 50 | + ILogger::ERROR => 3, |
|
| 51 | + ILogger::FATAL => 2, |
|
| 52 | + ]; |
|
| 53 | 53 | |
| 54 | - protected $syslogId; |
|
| 54 | + protected $syslogId; |
|
| 55 | 55 | |
| 56 | - public function __construct(IConfig $config) { |
|
| 57 | - if(!function_exists('sd_journal_send')) { |
|
| 58 | - throw new HintException( |
|
| 59 | - 'PHP extension php-systemd is not available.', |
|
| 60 | - 'Please install and enable PHP extension systemd if you wish to log to the Systemd journal.'); |
|
| 56 | + public function __construct(IConfig $config) { |
|
| 57 | + if(!function_exists('sd_journal_send')) { |
|
| 58 | + throw new HintException( |
|
| 59 | + 'PHP extension php-systemd is not available.', |
|
| 60 | + 'Please install and enable PHP extension systemd if you wish to log to the Systemd journal.'); |
|
| 61 | 61 | |
| 62 | - } |
|
| 63 | - $this->syslogId = $config->getSystemValue('syslog_tag', 'Nextcloud'); |
|
| 64 | - } |
|
| 62 | + } |
|
| 63 | + $this->syslogId = $config->getSystemValue('syslog_tag', 'Nextcloud'); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Write a message to the log. |
|
| 68 | - * @param string $app |
|
| 69 | - * @param string $message |
|
| 70 | - * @param int $level |
|
| 71 | - * @suppress PhanUndeclaredMethod |
|
| 72 | - */ |
|
| 73 | - public function write(string $app, $message, int $level) { |
|
| 74 | - $journal_level = $this->levels[$level]; |
|
| 75 | - sd_journal_send('PRIORITY='.$journal_level, |
|
| 76 | - 'SYSLOG_IDENTIFIER='.$this->syslogId, |
|
| 77 | - 'MESSAGE={'.$app.'} '.$message); |
|
| 78 | - } |
|
| 66 | + /** |
|
| 67 | + * Write a message to the log. |
|
| 68 | + * @param string $app |
|
| 69 | + * @param string $message |
|
| 70 | + * @param int $level |
|
| 71 | + * @suppress PhanUndeclaredMethod |
|
| 72 | + */ |
|
| 73 | + public function write(string $app, $message, int $level) { |
|
| 74 | + $journal_level = $this->levels[$level]; |
|
| 75 | + sd_journal_send('PRIORITY='.$journal_level, |
|
| 76 | + 'SYSLOG_IDENTIFIER='.$this->syslogId, |
|
| 77 | + 'MESSAGE={'.$app.'} '.$message); |
|
| 78 | + } |
|
| 79 | 79 | } |