cymapgt/logger
Composer 安装命令:
composer require cymapgt/logger
包简介
Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level
关键字:
README 文档
README
Wrapper for Monolog library. Implements custom log levels out of the box. Based on the log importance, custom logger levels allow logging to file, email, sms or a combination of either /all
Description
The logger package stands on the shoulders of giants; Monolog library is PHP's de facto logger which supports multiple channels, as well as building of custom channels, as has been done with the SmsChannel of the cymapgt logger. As such, most of the logger implementation is dedicated to configuration, with the heavy logging work being delegated to the elegant Monolog.
Installing
Install application via Composer
require "cymapgt/logger" : "^1.0.0"
Usage
Overview
The logger package implements the following Logger strategy:
-Stderr Logger: This can be loaded in order to provide Stream Logging capability for CLI applications
-Logger Level1: This application will provide basic logging services to just the default destination. The default destination for this logger is usually either a file or a database. As such, the log directory will have to be provided. Another option is database, but this is not implemented for now.
-Logger Level 2: This will still provide logging services to the log file as well as to email. It is utilized for log items that need more immediate attention.
-Logger Level 3: This will provide logging services to the log file, to email as well as to SMS. The idea behind the strategy is to enable graceful escalation in the event that an application may need to provide a more responsive log message by gradually choosing which log level to use.
-Logger Security: The security logger will provide security related logs to a separate secure file
-Logger Alert: This is still in design, and is an escalated level of the Logger Security class
Using the Logger package
Named Constants
//Log levels for Logger Class
if (!(defined('LOGGER_STDERR'))) {
define('LOGGER_STDERR', 0);
}
if (!(defined('LOGGER_LEVEL1'))) {
define('LOGGER_LEVEL1', 1);
}
if (!(defined('LOGGER_LEVEL2'))) {
define('LOGGER_LEVEL2', 2);
}
if (!(defined('LOGGER_LEVEL3'))) {
define('LOGGER_LEVEL3', 3);
}
if (!(defined('LOGGER_SECURITY'))) {
define('LOGGER_SECURITY', 4);
}
Bootstraping the Logger
You need to have the bootstrap package, which you will use to set up the [logger] group configurations for this package in the file cymapgt.network.ini; for example.
See cymapgt/bootstrap documentation for how to run this configuration.
[logger]
logger_file_location = '/var/www/html/logger_test.txt'
logger_security_file_location = '/var/www/html/logger_security.txt'
logger_email_alert_administrators = '{"cogana@gmail.com": "Cyril Ogana"}'
logger_sms_alert_administrators = '254123456789'
logger_email_alert_subject = 'SYSTEM IMPORTANT LOG MESSAGE ALERT'
logger_email_security_alert_administrators = '{"cogana@gmail.com": "Cyril Ogana"}'
logger_sms_security_alert_administrators = '254123456789'
logger_email_security_alert_subject = 'SYSTEM IMPORTANT LOG MESSAGE ALERT'
Logging Example
use cymapgt\core\utility\bootstrap\Bootstrap;
use cymapgt\core\utility\logger\Logger;
$loggerDbError = Logger::getLogger(\LOGGER_SECURITY, Bootstrap::LoggerSecurityParams());
$loggerDbError->addError('Critical error, the core database is down'); //log to file, email and sms
Testing
PHPUnit Tests are provided with the package
Contribute
- Email @rhossis or contact via Skype
- You will be added as author for contributions
License
BSD 3-clause
cymapgt/logger 适用场景与选型建议
cymapgt/logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 67 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Monolog Wrapper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cymapgt/logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cymapgt/logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cymapgt/logger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A GeoIP decorator/processor for monolog
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
A Zend Framework module that sets up Monolog for logging in applications.
Laravel 5.6 Monolog custom telegram channel
A Monolog processor to add X-Request-Id or UNIQUE_ID env to monolog stack if present, provide a default one otherwise. Optionally, add a forwarded request-id list.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
统计信息
- 总下载量: 67
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-06-27