mongdch/mon-log
最新稳定版本:1.0.6
Composer 安装命令:
composer require mongdch/mon-log
包简介
The Logger Utils for PSR-3.
README 文档
README
基于PSR-3实现的高扩展性日志驱动库
使用
Logger
// 解析器 $format = new LineFormat(); // 记录器 $record = new FileRecord([ // 日志文件大小 'maxSize' => 20480000, // 日志目录 'logPath' => __DIR__ . '/log', // 日志滚动卷数 'rollNum' => 3, // 日志名称,空则使用当前日期作为名称 'logName' => '', ]); $logger = new Logger($format, $record); // 记录日志 $logger->notice('Test notice log'); $logger->info('Test info log', ['trace' => true]);
LoggerFactiry
// 配置信息 $config = [ // 通道 'default' => [ // 解析器 'format' => [ // 类名 'handler' => LineFormat::class, // 配置信息 'config' => [] ], // 记录器 'record' => [ // 类名 'handler' => FileRecord::class, // 配置信息 'config' => [ // 日志文件大小 'maxSize' => 20480000, // 日志目录 'logPath' => __DIR__ . '/log', // 日志滚动卷数 'rollNum' => 3, // 日志名称,空则使用当前日期作为名称 'logName' => '', ] ] ], 'json' => [ // 解析器 'format' => [ // 类名 'handler' => JsonFormat::class, // 配置信息 'config' => [] ], // 记录器 'record' => [ // 类名 'handler' => FileRecord::class, // 配置信息 'config' => [ 'logPath' => __DIR__ . '/log/json', ] ] ] ]; // 注册日志工厂 $factory = LoggerFactory::instance()->registerChannel($config); // 记录日志 $factory->channel('default')->info('test log'); $factory->channel('json')->info('test json log'); $factory->channel()->debug('test trace log', ['trace' => true]);
extend
参考 examples/extend.php 文件
统计信息
- 总下载量: 217
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-16