Handle log_type "nextcloud" more gracefully
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
6a0f0403d0
commit
7573fa3148
|
@ -106,12 +106,8 @@ class Log implements ILogger {
|
||||||
|
|
||||||
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
|
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
|
||||||
if($logger === null) {
|
if($logger === null) {
|
||||||
// TODO: Drop backwards compatibility for config in the future
|
|
||||||
$logType = $this->config->getValue('log_type', 'file');
|
$logType = $this->config->getValue('log_type', 'file');
|
||||||
if($logType==='owncloud') {
|
$this->logger = static::getLogClass($logType);
|
||||||
$logType = 'file';
|
|
||||||
}
|
|
||||||
$this->logger = 'OC\\Log\\'.ucfirst($logType);
|
|
||||||
call_user_func(array($this->logger, 'init'));
|
call_user_func(array($this->logger, 'init'));
|
||||||
} else {
|
} else {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
@ -327,4 +323,25 @@ class Log implements ILogger {
|
||||||
$msg .= ': ' . json_encode($exception);
|
$msg .= ': ' . json_encode($exception);
|
||||||
$this->error($msg, $context);
|
$this->error($msg, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $logType
|
||||||
|
* @return string
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public static function getLogClass($logType) {
|
||||||
|
// TODO: Drop backwards compatibility for config in the future
|
||||||
|
switch (strtolower($logType)) {
|
||||||
|
case 'owncloud':
|
||||||
|
case 'nextcloud':
|
||||||
|
$logType = 'file';
|
||||||
|
}
|
||||||
|
$logClass = 'OC\\Log\\' . ucfirst($logType);
|
||||||
|
|
||||||
|
if (!class_exists($logClass)) {
|
||||||
|
$logClass = 'OC\\Log\\File';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $logClass;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,9 +418,8 @@ class Server extends ServerContainer implements IServerContainer {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
$this->registerService('Logger', function (Server $c) {
|
$this->registerService('Logger', function (Server $c) {
|
||||||
$logClass = $c->query('AllConfig')->getSystemValue('log_type', 'file');
|
$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
|
||||||
// TODO: Drop backwards compatibility for config in the future
|
$logger = Log::getLogClass($logType);
|
||||||
$logger = 'OC\\Log\\' . ucfirst($logClass=='owncloud' ? 'file' : $logClass);
|
|
||||||
call_user_func(array($logger, 'init'));
|
call_user_func(array($logger, 'init'));
|
||||||
|
|
||||||
return new Log($logger);
|
return new Log($logger);
|
||||||
|
|
Loading…
Reference in New Issue