Better fallback for unknown log types
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
e7ff1ba548
commit
7fa063ceca
|
@ -330,18 +330,19 @@ class Log implements ILogger {
|
|||
* @internal
|
||||
*/
|
||||
public static function getLogClass($logType) {
|
||||
// TODO: Drop backwards compatibility for config in the future
|
||||
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 '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() {
|
||||
return [
|
||||
['owncloud', \OC\Log\File::class],
|
||||
['nextcloud', \OC\Log\File::class],
|
||||
['file', \OC\Log\File::class],
|
||||
['errorlog', \OC\Log\Errorlog::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