summaryrefslogtreecommitdiffstats
path: root/lib/private/Log.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-01-05 12:47:27 +0100
committerJoas Schilling <coding@schilljs.com>2017-01-05 12:47:27 +0100
commit7573fa3148cf4ef99075e5373e40b776c0939f17 (patch)
tree7f673abf429d399bdede8d57275bccf2bc627b26 /lib/private/Log.php
parent6a0f0403d01dc6a889157b446edef73f9af58540 (diff)
downloadnextcloud-server-7573fa3148cf4ef99075e5373e40b776c0939f17.tar.gz
nextcloud-server-7573fa3148cf4ef99075e5373e40b776c0939f17.zip
Handle log_type "nextcloud" more gracefully
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Log.php')
-rw-r--r--lib/private/Log.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index ef1b70d3cb9..af0ca140cb9 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,25 @@ class Log implements ILogger {
$msg .= ': ' . json_encode($exception);
$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;
+ }
}