diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-03 11:45:27 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-03 11:45:27 +0200 |
commit | 3f944753e6712d63b3b89dd2060c586c1277f621 (patch) | |
tree | bafe970573241bdb0cb737e36dcbd820715dcf45 | |
parent | 547830d97edd2c4da46a2d7988873fdc65e00bb4 (diff) | |
parent | 03f1a270cc4476f9396f256db1967ee3a18d6e83 (diff) | |
download | nextcloud-server-3f944753e6712d63b3b89dd2060c586c1277f621.tar.gz nextcloud-server-3f944753e6712d63b3b89dd2060c586c1277f621.zip |
Merge pull request #24404 from owncloud/log_psr4
Move from OC_Log_XX to \OC\Log
-rw-r--r-- | core/Command/Log/Manage.php | 2 | ||||
-rw-r--r-- | lib/private/Log.php | 2 | ||||
-rw-r--r-- | lib/private/Log/ErrorHandler.php (renamed from lib/private/log/errorhandler.php) | 0 | ||||
-rw-r--r-- | lib/private/Log/Errorlog.php (renamed from lib/private/log/errorlog.php) | 4 | ||||
-rw-r--r-- | lib/private/Log/Owncloud.php (renamed from lib/private/log/owncloud.php) | 16 | ||||
-rw-r--r-- | lib/private/Log/Rotate.php (renamed from lib/private/log/rotate.php) | 0 | ||||
-rw-r--r-- | lib/private/Log/Syslog.php (renamed from lib/private/log/syslog.php) | 4 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | settings/Controller/LogSettingsController.php | 2 | ||||
-rw-r--r-- | tests/lib/log/owncloud.php | 15 |
10 files changed, 29 insertions, 18 deletions
diff --git a/core/Command/Log/Manage.php b/core/Command/Log/Manage.php index 1d65d7ed0d8..aeaaca8aa0e 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 d82346bbcf0..9248070c067 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 index 8899bcfcb03..8899bcfcb03 100644 --- a/lib/private/log/errorhandler.php +++ b/lib/private/Log/ErrorHandler.php diff --git a/lib/private/log/errorlog.php b/lib/private/Log/Errorlog.php index ad3605136d0..37498c36aba 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 index 9c106299e4c..13997a0d552 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 index 458661c82d0..458661c82d0 100644 --- a/lib/private/log/rotate.php +++ b/lib/private/Log/Rotate.php diff --git a/lib/private/log/syslog.php b/lib/private/Log/Syslog.php index 96cf463d042..115103f26d6 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 a98ddc36b58..7fe20561af9 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 c0c9ee04ca3..70a2b752359 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 adecc49768c..e19063a83f5 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 <http://www.gnu.org/licenses/>. */ +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'); |