Browse Source

fix(logging): Fix array to string conversion in errorlog writer

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
tags/v26.0.0beta1
Christoph Wurst 1 year ago
parent
commit
58a0740794
No account linked to committer's email address

+ 8
- 5
lib/private/Log/Errorlog.php View File

@@ -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));
}
}

+ 2
- 2
lib/private/Log/LogFactory.php View File

@@ -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':

+ 1
- 1
lib/private/Log/Syslog.php View File

@@ -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) {

+ 1
- 1
lib/private/Log/Systemdlog.php View File

@@ -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) {

+ 4
- 0
lib/public/Log/IWriter.php View File

@@ -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);
}

Loading…
Cancel
Save