0x20h/monoconf
最新稳定版本:0.1.1
Composer 安装命令:
composer require 0x20h/monoconf
包简介
log4j like logging configuration for the monolog framework
README 文档
README
Monoconf
log4j like configuration for the monolog logging framework.
Usage
- Create a config JSON file:
{
"rules": {
"*": {
"error": {
"handler": ["error-handler"]
}
},
"MyApp\\Controller*": {
"debug": {
"handler": ["debug-handler"],
"processor": ["pid"]
},
"error": {
"handler": ["error-handler"]
}
}
},
"handler": {
"error-handler": {
"type": "Monolog\\Handler\\StreamHandler",
"args": [
"/my/app/error.log"
],
"formatter": "line"
},
"debug-handler": {
"type": "Monolog\\Handler\\StreamHandler",
"args": [
"/my/app/application.log"
],
"formatter": "line"
}
},
"formatter": {
"line": {
"type": "Monolog\\Formatter\\LineFormatter",
"args": [
"%datetime% %pid% %channel%@%level_name% %message% %context%\n"
]
}
},
"processor": {
"pid": {
"type": "Monolog\\Processor\\ProcessIdProcessor",
"args": [
]
}
}
}
- In your application:
require 'vendor/autoload.php'; use Monoconf\Monoconf; // initialize monoconf Monoconf::config(json_decode(file_get_contents('monoconf.json'), true));
namespace MyApp\Controller; class SomeController { protected $Log; public function __construct() { self::$Log = \Monoconf\Monoconf::getLogger(__CLASS__); } public function someAction() { self::$Log->debug(__METHOD__.' called'); } }
Using this setup every class in the MyApp\Controller namespace will get a
logger that logs every message up to debug to /my/app/error.log and every
other class will get a logger that logs messages up to error to
/my/app/error.log.
Tests
phpunit --bootstrap tests/bootstrap.php tests/
统计信息
- 总下载量: 25.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-06-03