summaryrefslogtreecommitdiffstats
path: root/lib/private/Log
diff options
context:
space:
mode:
authorJohannes Ernst <jernst@indiecomputing.com>2018-06-18 18:29:31 +0000
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-06-29 10:37:46 +0200
commit72340b2230841b33998a52fe62d6cbbf0eeb4fc3 (patch)
tree43e1d3c39f6c6effe07e89fbb7432165d5cdf7b1 /lib/private/Log
parent0a65e62f29664730ac1aabcb612301be329ceed2 (diff)
downloadnextcloud-server-72340b2230841b33998a52fe62d6cbbf0eeb4fc3.tar.gz
nextcloud-server-72340b2230841b33998a52fe62d6cbbf0eeb4fc3.zip
Added Systemd.log documentation to config.sample.php
Changed name of default system (not systemd) logger from ownCloud to Nextcloud, to be consistent Fixed license per https://github.com/nextcloud/server/pull/9760#discussion_r195026784 Pulled upstream updates Signed-off-by: Johannes Ernst <jernst@indiecomputing.com>
Diffstat (limited to 'lib/private/Log')
-rw-r--r--lib/private/Log/Syslog.php2
-rw-r--r--lib/private/Log/Systemdlog.php16
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/Log/Syslog.php b/lib/private/Log/Syslog.php
index 90a20026f0e..b652eb4343d 100644
--- a/lib/private/Log/Syslog.php
+++ b/lib/private/Log/Syslog.php
@@ -39,7 +39,7 @@ class Syslog implements IWriter {
];
public function __construct(IConfig $config) {
- openlog($config->getSystemValue('syslog_tag', 'ownCloud'), LOG_PID | LOG_CONS, LOG_USER);
+ openlog($config->getSystemValue('syslog_tag', 'Nextcloud'), LOG_PID | LOG_CONS, LOG_USER);
}
public function __destruct() {
diff --git a/lib/private/Log/Systemdlog.php b/lib/private/Log/Systemdlog.php
index 63b228bfa0e..40e9c12386e 100644
--- a/lib/private/Log/Systemdlog.php
+++ b/lib/private/Log/Systemdlog.php
@@ -4,7 +4,7 @@
*
* @author Johannes Ernst <jernst@indiecomputing.com>
*
- * @license AGPL-3.0
+ * @license GNU AGPL version 3 or any later version
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
@@ -22,6 +22,7 @@
namespace OC\Log;
+use OC\HintException;
use OCP\ILogger;
use OCP\IConfig;
use OCP\Log\IWriter;
@@ -50,11 +51,20 @@ class Systemdlog implements IWriter {
ILogger::FATAL => 2,
];
+ protected $syslogId;
+
public function __construct(IConfig $config) {
+ if(!function_exists('sd_journal_send')) {
+ throw new HintException(
+ 'PHP extension php-systemd is not available.',
+ 'Please install and enable PHP extension systemd if you wish to log to the Systemd journal.');
+
+ }
+ $this->syslogId = $config->getSystemValue('syslog_tag', 'Nextcloud');
}
/**
- * write a message in the log
+ * Write a message to the log.
* @param string $app
* @param string $message
* @param int $level
@@ -62,7 +72,7 @@ class Systemdlog implements IWriter {
public function write(string $app, $message, int $level) {
$journal_level = $this->levels[$level];
sd_journal_send('PRIORITY='.$journal_level,
- 'SYSLOG_IDENTIFIER=nextcloud',
+ 'SYSLOG_IDENTIFIER='.$this->syslogId,
'MESSAGE={'.$app.'} '.$message);
}
}