const ERROR=3;
const FATAL=4;
+ static private $level_funcs = array(
+ self::DEBUG => 'debug',
+ self::INFO => 'info',
+ self::WARN => 'warning',
+ self::ERROR => 'error',
+ self::FATAL => 'emergency',
+ );
+
static public $enabled = true;
static protected $class = null;
*/
public static function write($app, $message, $level) {
if (self::$enabled) {
- if (!self::$class) {
- self::$class = 'OC_Log_'.ucfirst(OC_Config::getValue('log_type', 'owncloud'));
- call_user_func(array(self::$class, 'init'));
- }
- $log_class=self::$class;
- $log_class::write($app, $message, $level);
+ $context = array('app' => $app);
+ $func = array(self::$object, self::$level_funcs[$level]);
+ call_user_func($func, $message, $context);
}
}
*/
class Log {
- const NOTICE=5;
- const CRITICAL=6;
- const ALERT=7;
-
/**
* System is unusable.
*
$this->log(\OC_Log::DEBUG, $message, $context);
}
+ public function __construct() {
+ $this->log_class = 'OC_Log_'.ucfirst(\OC_Config::getValue('log_type', 'owncloud'));
+ call_user_func(array($this->log_class, 'init'));
+ }
+
/**
* Logs with an arbitrary level.
*
} else {
$app = 'no app in context';
}
- \OC_Log::write($app, $message, $level);
+ $log_class=$this->log_class;
+ $log_class::write($app, $message, $level);
}
}