定制 mimmi20/monolog-laminas-factory 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mimmi20/monolog-laminas-factory

最新稳定版本:2.0.1

Composer 安装命令:

composer require mimmi20/monolog-laminas-factory

包简介

Provides a Factory to build a Laminas Logger using Monolog.

README 文档

README

Monolog Factories for Laminas and Mezzio

This library was inspired by psr11-monolog and monolog-factory.

Latest Stable Version Latest Unstable Version License

Code Status

codecov Average time to resolve an issue Percentage of issues still open

Table of Contents

Installation

Run

composer require mimmi20/monolog-laminas-factory

Usage with Laminas and Mezzio

You'll need to add configuration and register the services you'd like to use. There are number of ways to do that but the recommended way is to create a new config file config/autoload/logger.config.php

Configuration

config/autoload/monolog.global.php

<?php
return [
    'log' => [
        \Laminas\Log\Logger::class => [
            'name' => 'name',
            'exceptionhandler' => false,
            'errorhandler' => false,
            'shutdownhandler' => false,
            'writers' => [], // Writers for Laminas Log
            'processors' => [], // Processors for Laminas Log
            'handlers' => [ // Handlers for Monolog
                // At the bare minimum you must include a default handler config.
                // Otherwise log entries will be sent to the void.
                'default' => [
                    'type' => 'stream',
                    'enabled' => true,
                    'options' => [
                        'stream' => '/var/log/some-log-file.txt',
                    ],
                ],
                
                // Another Handler
                'myOtherHandler' => [
                    'type' => 'stream',
                    'enabled' => false,
                    'options' => [
                        'stream' => '/var/log/someother-log-file.txt',
                    ],
                ],
            ],
            'monolog_processors' => [], // Processors for Monolog
        ],
    ],
];

Minimal Configuration

A minimal configuration would consist of at least one default handler and one named service. Please note that if you don't specify a default handler a NullHandler will be used when you wire up the default logger.

Minimal Example (using Mezzio for the example)

<?php

return [
    'log' => [
        \Laminas\Log\Logger::class => [
            'name' => 'name',
            'handlers' => [
                'default' => [
                    'type' => 'stream',
                    'options' => [
                        'stream' => '/var/log/some-log-file.txt',
                    ],
                ],
            ],
        ],
    ],
];

Full Configuration

Full Example

<?php

return [
    
    'log' => [
        \Laminas\Log\Logger::class => [
            'name' => 'name',
            'handlers' => [
                'default' => [
                    // A Handler type or pre-configured service from the container
                    'type' => 'stream',
                    
                    // Handler specific options.  See handlers below
                    'options' => [
                        'stream' => '/tmp/log_one.txt',
                    
                        // Optional: Formatter for the handler.
                        'formatter' => [
                            'type' => 'line',
                                
                            // formatter specific options.  See formatters below
                            'options' => [], 
                        ], 
                        
                        // Optional: Processor for the handler
                        'processors' => [
                            [
                                // A processor type or pre-configured service from the container
                                'type' => 'psrLogMessage',
                                
                                // processor specific options.  See processors below
                                'options' => [], 
                            ],
                        ],
                    ], 
                ],
            ],
            
            // Processors for Monolog/Logger
            'monolog_processors' => [
                // Array Keys are the names used for the processors
                'processorOne' => [
                    // A processor type or pre-configured service from the container
                    'type' => 'psrLogMessage',
                    
                    // processor specific options.  See processors below
                    'options' => [], 
                ],        
            ],
        ],
    ],
];

License

This package is licensed using the MIT License.

Please have a look at LICENSE.md.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-13