jenner/log-monitor
Composer 安装命令:
composer require jenner/log-monitor
包简介
monitoring and alerting of error log
关键字:
README 文档
README
An active log monitor based on the tail command.
Why use log-monitor?
Sometimes we want to know what is happening when crontab task is running or what errors had been written into the php error log by php script, and we want to know quickly. log-monitor can help you to monitor the log and notify the users who want to know.
What can log-monitor do?
- monitor the log by the tail command
- notify users when there is an error
- custom log filter interface, which will check the log is error or not
- custom notification interface, which will notify the users
- custom reader interface, if you do not want to use the tail command
How to use log-monitor?
talk is cheap, show you the code:
$reader = new \Jenner\LogMonitor\Reader\Reader('/var/log/messages'); $filter = new Jenner\LogMonitor\Filter\MatchFilter("exception"); $notify = new \Jenner\LogMonitor\Notification\EchoNotification(); $process = new \Jenner\LogMonitor\MonitorTask($reader, $filter, $notify); $process->run(); $process->wait();
There are three interfaces:AbstractReader, NotificationInterface, FilterInterface.
If you want to read log for somewhere else, you can create a class which extends AbstractReader.
If you want to filter your log in different way, you can create a class which implements FilterInterface.
If you want to send message to somewhere else, you can create a class which implements NotificationInterface.
How it works?
When you have created a MonitorTask object and call the run method,
it will start a sub process and call the tail command in the sub process. Then it will
read from the pipe and check the log by filter that if it is error or not. If there is an
error, it will call the notification to notify the users who want to know.
Just do not forget to call wait method to wait the sub process.
If you have many logs to monitor, you can use the Monitor to manage them. show you the code:
$reader = new \Jenner\LogMonitor\Reader\Reader('/var/log/messages'); $filter = new Jenner\LogMonitor\Filter\MatchFilter("exception"); $notify = new \Jenner\LogMonitor\Notification\EchoNotification(); $task = new \Jenner\LogMonitor\MonitorTask($reader, $filter, $notify); $monitor = new \Jenner\LogMonitor\Monitor(); $monitor->addTask($task); $monitor->start();
Just remember that when you call the start method, do not forget to call wait method.
jenner/log-monitor 适用场景与选型建议
jenner/log-monitor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「monitor」 「log monitor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jenner/log-monitor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jenner/log-monitor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jenner/log-monitor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle to monitor and execute commands
Collections of statsd collectors with templated metric names
A Laravel package to monitor queue jobs.
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Laravel 5.x.x library for integration Monolog Sentry
Pacote simplificado para persistência de logs
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-17