huy / qclog
A package that allows you to use monolog more flexibly.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/huy/qclog
Requires
- php: >=5.5.9
This package is not auto-updated.
Last update: 2025-10-06 16:35:29 UTC
README
Monolog简单封装,可以方便的指定日志输出格式和日志路径。
usage
拷贝qclog.php
到app\config
目录下,默认的配置如下:
<?php return [ 'dateFormat' => "Y-m-d H:i:s", //时间格式 'outputFormat' => "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n", //日志格式 'userLog' => [ //'file' => '/var/log/php/user.log', 'dateFormat' => 'Y n j, g:i a' ], 'goodsLog' => [ 'file' => '/var/log/php/goods.log' ], ];
'dateFormat'和'outputFormat'指定时间格式和日志输出格式。
'userLog'和'goodsLog'里面配置的'dateFormat'和'outputFormat'会覆盖外层配置。
'file'配置日志输出的文件。
然后可以这样使用:
use Qc\QcLog; QcLog::userLog()->addInfo('hello'); QcLog::goodsLog()->addWarning('this goods is missing'); QcLog::addInfo('this message will be wirtten in storage/logs/laravel.log');
类似addInfo
的方法有:
'addInfo', 'addDebug', 'addNotice', 'addWarning','addEmergency', 'addAlert', 'addCritical', 'addError'
这些是monolog基础方法。