phapi/log
最新稳定版本:1.0.0
Composer 安装命令:
composer require phapi/log
包简介
Phapi Log contains a Di container validator
关键字:
README 文档
README
Package contains a Di Container Validator for validating loggers.
Configuration
Loggers must be PSR-3 compatible. If no logger is configured or if the configured logger doesn't comply with PSR-3 then the NullLogger that is supplied in the PSR-3 package will be used.
In this example we will configure and use Monolog and set up a simple logger that logs to a file.
First, add the needed dependency to composer.json:
$ composer require monolog/monolog:1.*
After that it's just a matter of updating the configuration:
<?php use Monolog\Logger; use Monolog\Handler\StreamHandler; $container['log'] = function ($container) { $log = new Logger('default'); // IMPORTANT! Make sure you use an absolute path. Relative paths aren't guaranteed to // work in cases where errors and exceptions occur. $log->pushHandler(new StreamHandler(__DIR__ . '/../logs/logfile.log', Logger::WARNING)); return $log; };
Usage
<?php // add records to the log $container['log']->warning('Foo'); $container['log']->error('Bar');
License
Phapi Log is licensed under the MIT License - see the license.md file for details
Contribute
Contribution, bug fixes etc are always welcome.
统计信息
- 总下载量: 1.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-12