]> source.dussan.org Git - nextcloud-server.git/commitdiff
Better fallback for unknown log types 2951/head
authorJoas Schilling <coding@schilljs.com>
Tue, 10 Jan 2017 11:58:23 +0000 (12:58 +0100)
committerJoas Schilling <coding@schilljs.com>
Tue, 10 Jan 2017 11:59:13 +0000 (12:59 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Log.php
tests/lib/LoggerTest.php

index 5ba19698612df1262fa627738340e2249c9bf246..fddd359312736acacfa757b9cdf3f650923bf959 100644 (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;
        }
 }
index 8bae8d182283d7257ae9b5cb80d798568253ab8f..da9cedc9f56d808562db67b1fbf844e711b8e00d 100644 (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],
                ];
        }