johndodev/jlog-bundle 问题修复 & 功能扩展

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

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

johndodev/jlog-bundle

Composer 安装命令:

composer require johndodev/jlog-bundle

包简介

Easy logging.

README 文档

README

Installation

composer require johndodev/jlog-bundle

Configuration

.env

JLOG_API_KEY=your_api_key

config/packages/jlog.yaml

jlog:
    project_api_key: '%env(JLOG_API_KEY)%'
    enable_exception_listener: true
    ignore_exceptions:
        - Symfony\Component\HttpKernel\Exception\NotFoundHttpException
    # See chapter about logging commands
    console_channel: console

monolog.yaml

You need to use the buffer handler en amont.
See https://github.com/symfony/monolog-bundle/blob/master/DependencyInjection/Configuration.php#L139 for configuration options.
Ex :

monolog:
    channels:
        - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
        - command # same name as jlog.console_channel
    
    ...
    
    handlers:
        buffer:
            type: buffer
            handler: jlog
            level: debug # or whatever
            channels: ["app"]  # or whatever
            
        jlog:
            type: service
            id: jlog.monolog_handler

Usage

Logging commands

Extends Johndodev\JlogBundle\Console\LoggableOutputCommand in your command you want to log.
The start and end of commands will be logged in Jlog, in the channel you configured, with the output as metadata.

Logging exceptions

Unhandled exceptions are already logged (if enabled in config). You can still manually log them as usual, with monolog :

try {
    // ...
} catch (\Exception $e) {
    $this->logger->error('lorem ipsum...', [
        'exception' => $e->getMessage()
    ]);
}

Logging messages

With monologer, as usual.
It is recommanded to use placeholder, especially for errors which triggers notifications, because the message is used for signature for unique notification.

$this->logger->error('bla bla: {error}', [
    'error' => $e->getMessage()
]);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固