mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
Log类改进
This commit is contained in:
@@ -21,8 +21,12 @@ class Log {
|
||||
static public function init($config=[]){
|
||||
$type = isset($config['type'])?$config['type']:'File';
|
||||
$class = 'Think\\Log\\Driver\\'. ucwords($type);
|
||||
unset($config['type']);
|
||||
self::$storage = new $class($config);
|
||||
if(class_exists($class)) {
|
||||
unset($config['type']);
|
||||
self::$storage = new $class($config);
|
||||
}else{
|
||||
throw new \Exception('Log type not exists:'.$type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +71,7 @@ class Log {
|
||||
}
|
||||
self::$log = [];
|
||||
}
|
||||
self::$storage->write($message,$destination);
|
||||
self::$storage && self::$storage->write($message,$destination);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +83,7 @@ class Log {
|
||||
* @return void
|
||||
*/
|
||||
static public function write($log,$level,$destination='') {
|
||||
self::$storage->write("{$level}: {$log}",$destination);
|
||||
self::$storage && self::$storage->write("{$level}: {$log}",$destination);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user