Skip to content

Commit 58a0740

Browse files
fix(logging): Fix array to string conversion in errorlog writer
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent e12aaa2 commit 58a0740

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

lib/private/Log/Errorlog.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,27 @@
2828

2929
namespace OC\Log;
3030

31+
use OC\SystemConfig;
3132
use OCP\Log\IWriter;
3233

33-
class Errorlog implements IWriter {
34+
class Errorlog extends LogDetails implements IWriter {
3435

3536
/** @var string */
3637
protected $tag;
3738

38-
public function __construct(string $tag = 'nextcloud') {
39+
public function __construct(SystemConfig $config, string $tag = 'nextcloud') {
40+
parent::__construct($config);
3941
$this->tag = $tag;
4042
}
4143

4244
/**
43-
* write a message in the log
45+
* Write a message in the log
46+
*
4447
* @param string $app
45-
* @param string $message
48+
* @param string|array $message
4649
* @param int $level
4750
*/
4851
public function write(string $app, $message, int $level) {
49-
error_log('[' . $this->tag . ']['.$app.']['.$level.'] '.$message);
52+
error_log('[' . $this->tag . ']['.$app.']['.$level.'] '.$this->logDetailsAsJSON($app, $message, $level));
5053
}
5154
}

lib/private/Log/LogFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(IServerContainer $c, SystemConfig $systemConfig) {
4949
public function get(string $type):IWriter {
5050
switch (strtolower($type)) {
5151
case 'errorlog':
52-
return new Errorlog();
52+
return new Errorlog($this->systemConfig);
5353
case 'syslog':
5454
return $this->c->resolve(Syslog::class);
5555
case 'systemd':
@@ -73,7 +73,7 @@ public function getCustomLogger(string $path):ILogger {
7373
protected function createNewLogger(string $type, string $tag, string $path): IWriter {
7474
switch (strtolower($type)) {
7575
case 'errorlog':
76-
return new Errorlog($tag);
76+
return new Errorlog($this->systemConfig, $tag);
7777
case 'syslog':
7878
return new Syslog($this->systemConfig, $tag);
7979
case 'systemd':

lib/private/Log/Syslog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __destruct() {
5353
/**
5454
* write a message in the log
5555
* @param string $app
56-
* @param string $message
56+
* @param string|array $message
5757
* @param int $level
5858
*/
5959
public function write(string $app, $message, int $level) {

lib/private/Log/Systemdlog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct(SystemConfig $config, ?string $tag = null) {
7272
/**
7373
* Write a message to the log.
7474
* @param string $app
75-
* @param string $message
75+
* @param string|array $message
7676
* @param int $level
7777
*/
7878
public function write(string $app, $message, int $level) {

lib/public/Log/IWriter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
interface IWriter {
3131
/**
3232
* @since 14.0.0
33+
*
34+
* @param string $app
35+
* @param string|array $message
36+
* @param int $level
3337
*/
3438
public function write(string $app, $message, int $level);
3539
}

0 commit comments

Comments
 (0)