nvanheuverzwijn/monolog-logdna
Composer 安装命令:
composer require nvanheuverzwijn/monolog-logdna
包简介
Mezmo/Logdna handler for Monolog
README 文档
README
Monolog backend for mezmo/logdna. This backend use mezmo/logdna ingestion api.
Install
Install with compose composer require nvanheuverzwijn/monolog-logdna.
Usage
$logger = new \Monolog\Logger('general');
$logdnaHandler = new \Zwijn\Monolog\Handler\LogdnaHandler('your-key', 'myappname', \Monolog\Logger::DEBUG);
$logger->pushHandler($logdnaHandler);
# Sends debug level message "mylog" with some related meta-data
$logger->debug(
"mylog",
[
'logdna-meta-data-field1' => ['value1' => 'value', 'value2' => 5],
'logdna-meta-data-field2' => ['value1' => 'value']
]
);
Live Example
Create the following php script test.php. Don't forget to set the ingestion key prior to running this script.
<?php
include './vendor/autoload.php';
$INGESTION_KEY='';
\date_default_timezone_set('America/Montreal');
$logger = new \Monolog\Logger('general');
$logdnaHandler = new \Zwijn\Monolog\Handler\LogdnaHandler($INGESTION_KEY, 'appname', \Monolog\Logger::DEBUG);
$logger->pushHandler($logdnaHandler);
$logger->debug('mylog');
Execute it with the following docker command.
docker run -it --rm -v "${PWD}":/usr/src/myapp -w /usr/src/myapp php:8-cli php test.php
You should see the log 'mylog' with debug level in the mezmo/logdna account for which the ingestion key is bound to.
Using with Monolog Processors
Monolog Processors may add some extra data to the log records.
This data will appear in logdna log metadata as property monolog_extra unless it is empty.
If such a property already exists in the log record's context, it will be overwritten.
Time Drift Calculation
By default, the handler sends now parameter to the Ingestion API,
which is used to calculate time drift. You can disable sending this parameter via
$logdnaHandler->setIncludeRequestTime(false);
License
This project is licensed under LGPL3.0. See LICENSE file for details.
Versions
1.x is php5 with monolog 1.
2.x is php7 and php8 with monolog 2.
3.x is php8 with monolog 3.
Test
To test the project, simply call make or make test. Everything runs in docker container.
Clean
To clean your system, call make clean. Take note that if you use the same docker images as this project, you might not want to clean. Read the Makefile for more information.
Code Checks
To check for code smells, run make cs-check. To fix them, either do it manually or run make cs-fix.
nvanheuverzwijn/monolog-logdna 适用场景与选型建议
nvanheuverzwijn/monolog-logdna 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 249.39k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2017 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「log」 「logging」 「psr-3」 「logdna」 「mezmo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nvanheuverzwijn/monolog-logdna 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nvanheuverzwijn/monolog-logdna 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nvanheuverzwijn/monolog-logdna 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module that sets up Monolog for logging in applications.
PSR-3 compatible logger with dynamic file naming and hourly rotation, powered by Monolog
Chronolog is a tool that allows you to send logs to files, sockets, mailboxes, databases, etc.
Asynchronous Sentry for Symfony - Fire and forget
Wide logging implementation for PHP - one comprehensive, context-rich event per request
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
统计信息
- 总下载量: 249.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 20
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2017-05-15