diff --git a/demo.php b/demo.php index 56b9675..914f20f 100644 --- a/demo.php +++ b/demo.php @@ -28,6 +28,16 @@ slog('msg','alert');//将日志以alert方式弹出 slog('msg','log','color:red;font-size:20px;');//自定义日志的样式,第三个参数为css样式 +$i=5; +while($i){ + $typeArr = ['log','info','error','warn']; + $key = array_rand($typeArr,1); + echo $i; + slog(['hello word'.$i, 1, 2, [1,4,5]], $typeArr[$key]); + $i--; + sleep(1); +} + //调试sql /* $link=mysql_connect( 'localhost:3306' , 'root' , '123456' , true ) ; diff --git a/php/slog.php b/php/slog.php index 54b13f2..9eb4b89 100644 --- a/php/slog.php +++ b/php/slog.php @@ -42,7 +42,10 @@ public static function __callStatic($method,$args) if(in_array($method,self::$log_types)) { array_unshift($args,$method); - return call_user_func_array(array(self::getInstance(),'record'),$args); + $ret = call_user_func_array(array(self::getInstance(),'record'),$args); + self::sendLog(); + self::$logs=[]; + return $ret; } } @@ -489,7 +492,7 @@ protected static function sendToClient($tabid, $client_id, $logs, $force_client_ public function __destruct() { - self::sendLog(); + // self::sendLog(); } }