summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2022-12-19 14:17:39 +0100
committerGitHub <noreply@github.com>2022-12-19 14:17:39 +0100
commit6e22ba832d36d4ddb03d7d3ebf8955690f813a90 (patch)
tree0466184b97f3d431b6d3726bf03c96218504f791
parent75e369d3069fea662af7ef41378f8ef4460e3ce1 (diff)
parent58a07407945074af7022f3d93cdf1aa59fa32f1b (diff)
downloadnextcloud-server-6e22ba832d36d4ddb03d7d3ebf8955690f813a90.tar.gz
nextcloud-server-6e22ba832d36d4ddb03d7d3ebf8955690f813a90.zip
Merge pull request #35614 from nextcloud/fix/errorlog-array-to-string-conversion
Fix array to string conversion in errorlog writer
-rw-r--r--lib/private/Log/Errorlog.php13
-rw-r--r--lib/private/Log/LogFactory.php4
-rw-r--r--lib/private/Log/Syslog.php2
-rw-r--r--lib/private/Log/Systemdlog.php2
-rw-r--r--lib/public/Log/IWriter.php4
5 files changed, 16 insertions, 9 deletions
diff --git a/lib/private/Log/Errorlog.php b/lib/private/Log/Errorlog.php
index 7fca04d8b34..5c00528210a 100644
--- a/lib/private/Log/Errorlog.php
+++ b/lib/private/Log/Errorlog.php
@@ -28,24 +28,27 @@ declare(strict_types=1);
namespace OC\Log;
+use OC\SystemConfig;
use OCP\Log\IWriter;
-class Errorlog implements IWriter {
+class Errorlog extends LogDetails implements IWriter {
/** @var string */
protected $tag;
- public function __construct(string $tag = 'nextcloud') {
+ public function __construct(SystemConfig $config, string $tag = 'nextcloud') {
+ parent::__construct($config);
$this->tag = $tag;
}
/**
- * write a message in the log
+ * Write a message in the log
+ *
* @param string $app
- * @param string $message
+ * @param string|array $message
* @param int $level
*/
public function write(string $app, $message, int $level) {
- error_log('[' . $this->tag . ']['.$app.']['.$level.'] '.$message);
+ error_log('[' . $this->tag . ']['.$app.']['.$level.'] '.$this->logDetailsAsJSON($app, $message, $level));
}
}
diff --git a/lib/private/Log/LogFactory.php b/lib/private/Log/LogFactory.php
index 807ff501e39..2fdadc3bdb2 100644
--- a/lib/private/Log/LogFactory.php
+++ b/lib/private/Log/LogFactory.php
@@ -49,7 +49,7 @@ class LogFactory implements ILogFactory {
public function get(string $type):IWriter {
switch (strtolower($type)) {
case 'errorlog':
- return new Errorlog();
+ return new Errorlog($this->systemConfig);
case 'syslog':
return $this->c->resolve(Syslog::class);
case 'systemd':
@@ -73,7 +73,7 @@ class LogFactory implements ILogFactory {
protected function createNewLogger(string $type, string $tag, string $path): IWriter {
switch (strtolower($type)) {
case 'errorlog':
- return new Errorlog($tag);
+ return new Errorlog($this->systemConfig, $tag);
case 'syslog':
return new Syslog($this->systemConfig, $tag);
case 'systemd':
diff --git a/lib/private/Log/Syslog.php b/lib/private/Log/Syslog.php
index 8140b4ec77c..f4ba857742f 100644
--- a/lib/private/Log/Syslog.php
+++ b/lib/private/Log/Syslog.php
@@ -53,7 +53,7 @@ class Syslog extends LogDetails implements IWriter {
/**
* write a message in the log
* @param string $app
- * @param string $message
+ * @param string|array $message
* @param int $level
*/
public function write(string $app, $message, int $level) {
diff --git a/lib/private/Log/Systemdlog.php b/lib/private/Log/Systemdlog.php
index 00f242e3718..20a60623713 100644
--- a/lib/private/Log/Systemdlog.php
+++ b/lib/private/Log/Systemdlog.php
@@ -72,7 +72,7 @@ class Systemdlog extends LogDetails implements IWriter {
/**
* Write a message to the log.
* @param string $app
- * @param string $message
+ * @param string|array $message
* @param int $level
*/
public function write(string $app, $message, int $level) {
diff --git a/lib/public/Log/IWriter.php b/lib/public/Log/IWriter.php
index acc39533bfd..3c7ec84e8c0 100644
--- a/lib/public/Log/IWriter.php
+++ b/lib/public/Log/IWriter.php
@@ -30,6 +30,10 @@ namespace OCP\Log;
interface IWriter {
/**
* @since 14.0.0
+ *
+ * @param string $app
+ * @param string|array $message
+ * @param int $level
*/
public function write(string $app, $message, int $level);
}