Better fallback for unknown log types

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-01-10 12:58:23 +01:00
parent acf62afe2d
commit 78e685ce8f
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 14 additions and 11 deletions

View File

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

View File

@ -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],
];
}