mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
改进trace
This commit is contained in:
@@ -11,8 +11,17 @@
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* Class Log
|
||||
* @package think
|
||||
*
|
||||
* @method void log($msg) static
|
||||
* @method void error($msg) static
|
||||
* @method void info($msg) static
|
||||
* @method void sql($msg) static
|
||||
* @method void notice($msg) static
|
||||
* @method void alert($msg) static
|
||||
*/
|
||||
class Log
|
||||
{
|
||||
const LOG = 'log';
|
||||
@@ -30,16 +39,15 @@ class Log
|
||||
protected static $type = ['log', 'error', 'info', 'sql', 'notice', 'alert'];
|
||||
// 日志写入驱动
|
||||
protected static $driver;
|
||||
// 通知发送驱动
|
||||
protected static $alarm;
|
||||
|
||||
// 当前日志授权key
|
||||
protected static $key;
|
||||
|
||||
/**
|
||||
* 日志初始化
|
||||
* @return void
|
||||
* @param array $config
|
||||
*/
|
||||
public static function init($config = [])
|
||||
public static function init($config = [])
|
||||
{
|
||||
$type = isset($config['type']) ? $config['type'] : 'File';
|
||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
|
||||
@@ -49,21 +57,7 @@ class Log
|
||||
// 记录初始化信息
|
||||
App::$debug && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知初始化
|
||||
* @return void
|
||||
*/
|
||||
public static function alarm($config = [])
|
||||
{
|
||||
$type = isset($config['type']) ? $config['type'] : 'Email';
|
||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\log\\alarm\\' . ucwords($type);
|
||||
unset($config['type']);
|
||||
self::$alarm = new $class($config['alarm']);
|
||||
// 记录初始化信息
|
||||
App::$debug && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取日志信息
|
||||
* @param string $type 信息类型
|
||||
@@ -164,19 +158,11 @@ class Log
|
||||
return self::$driver->save($log);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送预警通知
|
||||
* @param mixed $msg 调试信息
|
||||
* @return void
|
||||
*/
|
||||
public static function send($msg)
|
||||
{
|
||||
self::$alarm && self::$alarm->send($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态调用
|
||||
* @return void
|
||||
* @param $method
|
||||
* @param $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user