gentenox/sentry-monolog-handler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gentenox/sentry-monolog-handler

最新稳定版本:v2.0.1

Composer 安装命令:

composer require gentenox/sentry-monolog-handler

包简介

Custom Sentry handler for Monolog for sending log context data to sentry eventsand it's focussed on ease-of-use and elegant syntax.

README 文档

README

Custom Sentry handler for Monolog for sending log context data to sentry events with additional event information and it's focussed on ease-of-use and elegant syntax

Installation

Install via composer

You can install the package using the Composer package manager. You can install it by running this command in your project root:

composer require gentenox/sentry-monolog-handler

Add config for monolog handler to config/packages/monolog.yaml

monolog:
  handlers:
    sentry:
      type: service
      id: monolog_context_handler

Add new service to services.yaml

monolog_context_handler:
  class: SentryMonologHandler\MonologContextHandler
  arguments:
    $hub: '@Sentry\State\HubInterface'
    $level: !php/const Monolog\Logger::ERROR

Basic Usage

In examples below used monolog logger that implements Psr\Log\LoggerInterface

Log error with context data

In this example sentry error handler receive logger context data end send it to Sentry as sentry event context data

$logger->error('Cannot find existing order for user', [
    'user_id' => $user->getId()
]);

Log with specific sentry properties

In this example sentry error handler receive logger context data and handle specific properties such as tags and fingerprint These specific properties will not be added to logs and used only for providing additional event information to Sentry

Field Type Description
MonologFields::Tags array Contains Sentry tags. Tags are key/value string pairs and used for filtering events
MonologFields::Fingerprint array Contains Sentry fingerprint. Events with the same fingerprint are grouped together into an issue
$logger->error('Invalid postback received', [
    MonologFields::Tags->value => ['scope' => 'postback_validation']
    MonologFields::Fingerprint->value => ['postback_validation_fingerprint']
]);

统计信息

  • 总下载量: 16.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-15