Better fallback for unknown log types
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
acf62afe2d
commit
78e685ce8f
|
@ -330,18 +330,19 @@ class Log implements ILogger {
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public static function getLogClass($logType) {
|
public static function getLogClass($logType) {
|
||||||
// TODO: Drop backwards compatibility for config in the future
|
|
||||||
switch (strtolower($logType)) {
|
switch (strtolower($logType)) {
|
||||||
|
case 'errorlog':
|
||||||
|
return \OC\Log\Errorlog::class;
|
||||||
|
case 'syslog':
|
||||||
|
return \OC\Log\Syslog::class;
|
||||||
|
case 'file':
|
||||||
|
return \OC\Log\File::class;
|
||||||
|
|
||||||
|
// Backwards compatibility for old and fallback for unknown log types
|
||||||
case 'owncloud':
|
case 'owncloud':
|
||||||
case 'nextcloud':
|
case 'nextcloud':
|
||||||
$logType = 'file';
|
default:
|
||||||
|
return \OC\Log\File::class;
|
||||||
}
|
}
|
||||||
$logClass = 'OC\\Log\\' . ucfirst($logType);
|
|
||||||
|
|
||||||
if (!class_exists($logClass)) {
|
|
||||||
$logClass = \OC\Log\File::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $logClass;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,13 @@ class LoggerTest extends TestCase {
|
||||||
|
|
||||||
public function dataGetLogClass() {
|
public function dataGetLogClass() {
|
||||||
return [
|
return [
|
||||||
['owncloud', \OC\Log\File::class],
|
|
||||||
['nextcloud', \OC\Log\File::class],
|
|
||||||
['file', \OC\Log\File::class],
|
['file', \OC\Log\File::class],
|
||||||
['errorlog', \OC\Log\Errorlog::class],
|
['errorlog', \OC\Log\Errorlog::class],
|
||||||
['syslog', \OC\Log\Syslog::class],
|
['syslog', \OC\Log\Syslog::class],
|
||||||
|
|
||||||
|
['owncloud', \OC\Log\File::class],
|
||||||
|
['nextcloud', \OC\Log\File::class],
|
||||||
|
['foobar', \OC\Log\File::class],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue