想要实现的功能
- 获取laravel运行时执行的sql语句
- sql相关的日志保存到指定文件(sql.log)
- 接口访问与artisan 命令日志分开保存
例如
- sql.log
[2017-10-21 22:27:42] production.DEBUG: select count(*) as aggregate from `stocks_input` where `stocks_input`.`deleted_at` is null; {"time":0.55}
[2017-10-21 22:27:42] production.DEBUG: select * from `stocks_input` where `stocks_input`.`deleted_at` is null order by `created_at` desc limit 10 offset 0; {"time":0.84}
[2017-10-21 22:27:42] production.DEBUG: select * from `goods` where `goods`.`id` = 1 limit 1; {"time":0.74}
- cli.sql.log
[2017-10-21 22:28:15] production.DEBUG: select * from `goods` where `goods`.`id` = 1 limit 1; {"time":0.76}
[2017-10-21 22:28:15] production.DEBUG: select * from `regions` where `regions`.`id` = 110102 limit 1; {"time":0.87}
[2017-10-21 22:28:15] production.DEBUG: select * from `regions` where `regions`.`id` = 110000 limit 1; {"time":0.81}