summaryrefslogtreecommitdiffstats
path: root/lib/private/Log.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Log.php')
-rw-r--r--lib/private/Log.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index ef1b70d3cb9..fddd3593127 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -106,12 +106,8 @@ class Log implements ILogger {
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
if($logger === null) {
- // TODO: Drop backwards compatibility for config in the future
$logType = $this->config->getValue('log_type', 'file');
- if($logType==='owncloud') {
- $logType = 'file';
- }
- $this->logger = 'OC\\Log\\'.ucfirst($logType);
+ $this->logger = static::getLogClass($logType);
call_user_func(array($this->logger, 'init'));
} else {
$this->logger = $logger;
@@ -327,4 +323,26 @@ class Log implements ILogger {
$msg .= ': ' . json_encode($exception);
$this->error($msg, $context);
}
+
+ /**
+ * @param string $logType
+ * @return string
+ * @internal
+ */
+ public static function getLogClass($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 'nextcloud':
+ default:
+ return \OC\Log\File::class;
+ }
+ }
}