mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进log类的write方法 增加log_write标签位 可用于绑定行为
增加send方法 用于发送预警(需要先alarm方法初始化)
This commit is contained in:
@@ -80,24 +80,34 @@ class Log
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时写入日志信息 并支持异常和错误预警通知
|
||||
* 实时写入日志信息 并支持行为
|
||||
* @param mixed $msg 调试信息
|
||||
* @param string $type 信息类型
|
||||
* @return void
|
||||
*/
|
||||
public static function write($msg, $type)
|
||||
public static function write($msg, $type = 'log')
|
||||
{
|
||||
if (!is_string($msg)) {
|
||||
$msg = print_r($msg, true);
|
||||
}
|
||||
if ('error' == $type) {
|
||||
// 预留预警通知接口
|
||||
self::$alarm && self::$alarm->send($msg);
|
||||
}
|
||||
// 封装日志信息
|
||||
$log[] = ['type' => $type, 'msg' => $msg];
|
||||
|
||||
// 监听log_write
|
||||
APP_HOOK && Hook::listen('log_write', $log);
|
||||
// 写入日志
|
||||
self::$driver && self::$driver->save($log);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送预警通知
|
||||
* @return void
|
||||
*/
|
||||
public static function send($msg)
|
||||
{
|
||||
self::$alarm && self::$alarm->send($msg);
|
||||
}
|
||||
|
||||
// 静态调用
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user