]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move logfile determination to init function
authorBart Visscher <bartv@thisnet.nl>
Fri, 30 Mar 2012 21:40:16 +0000 (23:40 +0200)
committerBart Visscher <bartv@thisnet.nl>
Fri, 30 Mar 2012 21:41:54 +0000 (23:41 +0200)
lib/log/owncloud.php

index 6df346e9b1759be0677da61515d61e6a3ebe7326..5e143205563144c82c91a591f7c084a70c318aa2 100644 (file)
  */
 
 class OC_Log_Owncloud {
+       static protected $logFile;
+
        /**
         * Init class data
         */
        public static function init() {
+               $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
+               self::$logFile=OC_Config::getValue( "logfile", $datadir.'/owncloud.log' );
        }
 
        /**
@@ -42,10 +46,8 @@ class OC_Log_Owncloud {
        public static function write($app, $message, $level) {
                $minLevel=OC_Config::getValue( "loglevel", 2 );
                if($level>=$minLevel){
-                       $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
-                       $logFile=OC_Config::getValue( "logfile", $datadir.'/owncloud.log' );
                        $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level,'time'=>time());
-                       $fh=fopen($logFile, 'a');
+                       $fh=fopen(self::$logFile, 'a');
                        fwrite($fh, json_encode($entry)."\n");
                        fclose($fh);
                }
@@ -58,10 +60,9 @@ class OC_Log_Owncloud {
         * @return array
         */
        public static function getEntries($limit=50, $offset=0){
-               $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
-               $logFile=OC_Config::getValue( "logfile", $datadir.'/owncloud.log' );
+               self::init();
                $entries=array();
-               if(!file_exists($logFile)) {
+               if(!file_exists(self::$logFile)) {
                        return array();
                }
                $contents=file($logFile);