Move logfile determination to init function
This commit is contained in:
parent
3300d6ea53
commit
20fc23c82b
|
@ -27,10 +27,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class OC_Log_Owncloud {
|
class OC_Log_Owncloud {
|
||||||
|
static protected $logFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init class data
|
* Init class data
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
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) {
|
public static function write($app, $message, $level) {
|
||||||
$minLevel=OC_Config::getValue( "loglevel", 2 );
|
$minLevel=OC_Config::getValue( "loglevel", 2 );
|
||||||
if($level>=$minLevel){
|
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());
|
$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");
|
fwrite($fh, json_encode($entry)."\n");
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
}
|
}
|
||||||
|
@ -58,10 +60,9 @@ class OC_Log_Owncloud {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getEntries($limit=50, $offset=0){
|
public static function getEntries($limit=50, $offset=0){
|
||||||
$datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
|
self::init();
|
||||||
$logFile=OC_Config::getValue( "logfile", $datadir.'/owncloud.log' );
|
|
||||||
$entries=array();
|
$entries=array();
|
||||||
if(!file_exists($logFile)) {
|
if(!file_exists(self::$logFile)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$contents=file($logFile);
|
$contents=file($logFile);
|
||||||
|
|
Loading…
Reference in New Issue