日志收集
在开发过程中封装一个slog函数记录接口信息可以实时的记录接口交互的信息,代码如下:
public function slog(){ $str = file_get_contents('log.txt'); $str .= "时间: ".date('Y-m-d H:i:s').' 类型: '.$this->msgType.' 事件: '.$this->postObj->Event.' 内容: '.$this->postObj->Content.' --------------------------------------------- '; file_put_contents('log.txt', $str); }
可以在构造函数中加入 slog函数,这样每次交互都会有信息记录。
日志查看
日志会累加在 log.txt文件中,浏览器中打开:
http://yourhost/log.txt 即可查看