mattmezza/logger
Composer 安装命令:
composer require mattmezza/logger
包简介
Lightweight package for logging purposes.
README 文档
README
This package is a small utility for logging purposes. It allows you to quickly set up a logging system.
Usage
The main component to use is LevelLogger. Just create a new instance and start logging.
$log = new LevelLogger(); $log->info('DONE.'); $log->debug('I\'m here.'); $log->error($exception->getMessage());
There are 3 levels namely info|debug|error that come handy when switching environment development|staging|production.
The package comes with 3 logging strategies namely:
STDOUT(default): it justechothe message (together with a timestamp and the log level)SYSLOG: calls thesyslog(...)function and logs the message (using the syslog format) to the system logFILE: appends the log message (together with the timestamp and log level) to a file that you specify
How do you specify the parameters?
The package reads from ENV variables. The following variables are used:
LOG_LEVEL: can be eitherINFO|DEBUG|ERRORand defaults toERRORto be the least verbose. When the log level isERRORall theinfoanddebugmessages will not be logged. When the log level is set toDEBUG, all theinfomessages will not be logged. When set toINFOinstead, all of the messages will be logged;LOG_STRATEGY: can be eitherSTDOUT|SYSLOG|FILEand defaults toSYSLOG. It sets the strategy. When theFILEstrategy is chosen, please specify the file path by using the next described variable;LOG_FILE_PATH: must be a writable file path. It defaults to/var/log/logger.log;
Development
You can add new loggers by implementing the Logger interface.
Further development
- Would be nice to add a file rotate feature when logging to file.
mattmezza/logger 适用场景与选型建议
mattmezza/logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mattmezza/logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mattmezza/logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 12
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-11