zero1/module-custom-logging 问题修复 & 功能扩展

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

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

zero1/module-custom-logging

Composer 安装命令:

composer require zero1/module-custom-logging

包简介

Allows you to configure different logging 'stacks' on a per environment basis. This would allow you to have a logging level of DEBUG on non_production and ERROR on production.

README 文档

README

Allows configurable logging, on a per environment basis. Whilst still keeping the logging configuration in source control.

100% compatible with Mdoq

To setup you will need to add the following snippets to the appropriate files.
On you production sites make sure you change the stack value to production.
In addition to this if you are running multiple webheads you can the hardware_instance value to identify each web head. eg admin-01, web-asg-01 this will then be added to the logs.

env.php Config Example

'logging' => [
        'hardware_instance' => 'server1-blahblah',
        'stack' => 'non_production'
    ],

config.php Config Example

'logging' => [
        'stacks' => [
            'production' => [
                'handlers' => [
                    'productionDefaultLogger' => [],
                ],
                'common_formatter' => \Monolog\Formatter\JsonFormatter::class,
                'common_processors' => [
                    \Monolog\Processor\GitProcessor::class,
                    \Monolog\Processor\IntrospectionProcessor::class,
                    \Monolog\Processor\WebProcessor::class,
                    \Zero1\CustomLogging\Logger\Processor\HardwareInstance::class,
                ]
            ],
            'non_production' => [
                'handlers' => [
                    'nonProductionDefaultLogger' => [],
                    'nonProductionDebugLogger' => [],
                ],
                'common_formatter' => 'loggingLineFormatter',
                'common_processors' => [
                    \Monolog\Processor\GitProcessor::class,
                    \Monolog\Processor\IntrospectionProcessor::class,
                    \Monolog\Processor\WebProcessor::class,
                    \Zero1\CustomLogging\Logger\Processor\HardwareInstance::class,
                ]
            ]
        ]
    ]

Additional Information

The changes you make in app/etc/env.php are meant to be environment specific. In here you can configure the logging 'stack' you want to use. This value will be out of source control. The 'stack' is purely a nice name to a set of logging configuration defined in app/etc/config.php. In app/etc/config.php you can configure as many different stacks as you want e.g 'production', 'staging', 'local'. Each of these stacks is stored in source control allowing the stacks to be used by anyone on your code base.

In addition to be able to change the 'stack' with a single environment value, we can also add additional things to all loggers, so that all messages get this info. The default example adds four 'processors' that add extra info.

'common_processors' => [
    \Monolog\Processor\GitProcessor::class,
    \Monolog\Processor\IntrospectionProcessor::class,
    \Monolog\Processor\WebProcessor::class,
    \Zero1\CustomLogging\Logger\Processor\HardwareInstance::class,
]

These will be added to all handlers:

'handlers' => [
    'nonProductionDefaultLogger' => [],
    'nonProductionDebugLogger' => [],
 ]

These link to the loggers that are defined in etc/di.xml

How this is different from Magento core:

  • In magento core, you would have to make changes in source controlled files to change the logging verbosity. (Not ideal as production should have the same source files as staging, yet they should have different logging verbosity / settings)
  • In magento core there is no way to configure different stacks of loggers.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2019-06-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固