diff --git a/core/Command/Log/Manage.php b/core/Command/Log/Manage.php index 1d65d7ed0d..aeaaca8aa0 100644 --- a/core/Command/Log/Manage.php +++ b/core/Command/Log/Manage.php @@ -115,7 +115,7 @@ class Manage extends Command { * @throws \InvalidArgumentException */ protected function validateBackend($backend) { - if (!class_exists('OC_Log_'.$backend)) { + if (!class_exists('OC\\Log\\'.ucfirst($backend))) { throw new \InvalidArgumentException('Invalid backend'); } } diff --git a/lib/private/Log.php b/lib/private/Log.php index d82346bbcf..9248070c06 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -73,7 +73,7 @@ class Log implements ILogger { // FIXME: Add this for backwards compatibility, should be fixed at some point probably if($logger === null) { - $this->logger = 'OC_Log_'.ucfirst($this->config->getValue('log_type', 'owncloud')); + $this->logger = 'OC\\Log\\'.ucfirst($this->config->getValue('log_type', 'owncloud')); call_user_func(array($this->logger, 'init')); } else { $this->logger = $logger; diff --git a/lib/private/log/errorhandler.php b/lib/private/Log/ErrorHandler.php similarity index 100% rename from lib/private/log/errorhandler.php rename to lib/private/Log/ErrorHandler.php diff --git a/lib/private/log/errorlog.php b/lib/private/Log/Errorlog.php similarity index 97% rename from lib/private/log/errorlog.php rename to lib/private/Log/Errorlog.php index ad3605136d..37498c36ab 100644 --- a/lib/private/log/errorlog.php +++ b/lib/private/Log/Errorlog.php @@ -23,7 +23,9 @@ * THE SOFTWARE. */ -class OC_Log_Errorlog { +namespace OC\Log; + +class Errorlog { /** diff --git a/lib/private/log/owncloud.php b/lib/private/Log/Owncloud.php similarity index 92% rename from lib/private/log/owncloud.php rename to lib/private/Log/Owncloud.php index 9c106299e4..13997a0d55 100644 --- a/lib/private/log/owncloud.php +++ b/lib/private/Log/Owncloud.php @@ -27,13 +27,15 @@ * */ +namespace OC\Log; + /** * logging utilities * * Log is saved at data/owncloud.log (on default) */ -class OC_Log_Owncloud { +class Owncloud { static protected $logFile; /** @@ -41,7 +43,7 @@ class OC_Log_Owncloud { */ public static function init() { $systemConfig = \OC::$server->getSystemConfig(); - $defaultLogFile = $systemConfig->getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log'; + $defaultLogFile = $systemConfig->getValue("datadirectory", \OC::$SERVERROOT.'/data').'/owncloud.log'; self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile); /** @@ -72,13 +74,13 @@ class OC_Log_Owncloud { $format = $config->getValue('logdateformat', 'c'); $logTimeZone = $config->getValue( "logtimezone", 'UTC' ); try { - $timezone = new DateTimeZone($logTimeZone); - } catch (Exception $e) { - $timezone = new DateTimeZone('UTC'); + $timezone = new \DateTimeZone($logTimeZone); + } catch (\Exception $e) { + $timezone = new \DateTimeZone('UTC'); } - $time = DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", "")); + $time = \DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", "")); if ($time === false) { - $time = new DateTime(null, $timezone); + $time = new \DateTime(null, $timezone); } else { // apply timezone if $time is created from UNIX timestamp $time->setTimezone($timezone); diff --git a/lib/private/log/rotate.php b/lib/private/Log/Rotate.php similarity index 100% rename from lib/private/log/rotate.php rename to lib/private/Log/Rotate.php diff --git a/lib/private/log/syslog.php b/lib/private/Log/Syslog.php similarity index 97% rename from lib/private/log/syslog.php rename to lib/private/Log/Syslog.php index 96cf463d04..115103f26d 100644 --- a/lib/private/log/syslog.php +++ b/lib/private/Log/Syslog.php @@ -21,7 +21,9 @@ * */ -class OC_Log_Syslog { +namespace OC\Log; + +class Syslog { static protected $levels = array( \OCP\Util::DEBUG => LOG_DEBUG, \OCP\Util::INFO => LOG_INFO, diff --git a/lib/private/Server.php b/lib/private/Server.php index a98ddc36b5..7fe20561af 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -329,7 +329,7 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService('Logger', function (Server $c) { $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud'); - $logger = 'OC_Log_' . ucfirst($logClass); + $logger = 'OC\\Log\\' . ucfirst($logClass); call_user_func(array($logger, 'init')); return new Log($logger); diff --git a/settings/Controller/LogSettingsController.php b/settings/Controller/LogSettingsController.php index c0c9ee04ca..70a2b75235 100644 --- a/settings/Controller/LogSettingsController.php +++ b/settings/Controller/LogSettingsController.php @@ -102,7 +102,7 @@ class LogSettingsController extends Controller { * @return StreamResponse */ public function download() { - $resp = new StreamResponse(\OC_Log_Owncloud::getLogFilePath()); + $resp = new StreamResponse(\OC\Log\Owncloud::getLogFilePath()); $resp->addHeader('Content-Disposition', 'attachment; filename="owncloud.log"'); return $resp; } diff --git a/tests/lib/log/owncloud.php b/tests/lib/log/owncloud.php index adecc49768..e19063a83f 100644 --- a/tests/lib/log/owncloud.php +++ b/tests/lib/log/owncloud.php @@ -15,12 +15,17 @@ * License along with this library. If not, see . */ +namespace Test\Log; + +use OC\Log\Owncloud; +use Test\TestCase; + /** - * Class Test_Log_Owncloud + * Class OwncloudTest * * @group DB */ -class Test_Log_Owncloud extends Test\TestCase +class OwncloudTest extends TestCase { private $restore_logfile; private $restore_logdateformat; @@ -32,7 +37,7 @@ class Test_Log_Owncloud extends Test\TestCase $this->restore_logdateformat = $config->getSystemValue('logdateformat'); $config->setSystemValue("logfile", $config->getSystemValue('datadirectory') . "/logtest"); - OC_Log_Owncloud::init(); + Owncloud::init(); } protected function tearDown() { $config = \OC::$server->getConfig(); @@ -46,7 +51,7 @@ class Test_Log_Owncloud extends Test\TestCase } else { $config->deleteSystemValue("restore_logdateformat"); } - OC_Log_Owncloud::init(); + Owncloud::init(); parent::tearDown(); } @@ -57,7 +62,7 @@ class Test_Log_Owncloud extends Test\TestCase # set format & write log line $config->setSystemValue('logdateformat', 'u'); - OC_Log_Owncloud::write('test', 'message', \OCP\Util::ERROR); + Owncloud::write('test', 'message', \OCP\Util::ERROR); # read log line $handle = @fopen($config->getSystemValue('logfile'), 'r');