From fd99559c59399a6d10c0654ec91ddfda3c017bd5 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 29 Dec 2015 10:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Blog=E7=B1=BB=E7=9A=84write?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E5=A2=9E=E5=8A=A0log=5Fwrite=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E4=BD=8D=20=E5=8F=AF=E7=94=A8=E4=BA=8E=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E8=A1=8C=E4=B8=BA=20=E5=A2=9E=E5=8A=A0send=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=E7=94=A8=E4=BA=8E=E5=8F=91=E9=80=81=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=EF=BC=88=E9=9C=80=E8=A6=81=E5=85=88alarm=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=88=9D=E5=A7=8B=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/log.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/library/think/log.php b/library/think/log.php index b97a829f..6df9fb95 100644 --- a/library/think/log.php +++ b/library/think/log.php @@ -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) {