geo6/mezzio-monolog

Mezzio Monolog 错误处理器

v2.0.2 2020-11-20 13:42 UTC

This package is auto-updated.

Last update: 2024-09-22 16:39:46 UTC


README

Latest Stable Version Total Downloads Monthly Downloads Software License

此库允许在 Mezzio 中将 Monolog 作为 ErrorHandler。

目前支持 2 个处理器(如果需要,还将添加更多)

安装

composer require geo6/mezzio-monolog

配置

在您的 config 目录中创建一个 monolog.global.php 文件

<?php

declare(strict_types=1);

return [
    // StreamHandler
    'stream' => [
        'path' => 'data/log/myapp.log',
    ],
    // SentryHanlder
    'sentry' => [
        'dsn' => 'https://xxxxx@sentry.io/12345',
    ],
];

使用方法

要启用它,只需将 Geo6\Mezzio\Monolog\ConfigProvider::class 添加到您的主配置(通常是 config/config.php)中

...

$aggregator = new ConfigAggregator([
+     Geo6\Mezzio\Monolog\ConfigProvider::class,

    ...
], $cacheConfig['config_cache_path']);

...

Monolog ErrorHandler 只在 "生产模式"(当 $config['debug']false 时)下生效。
要切换到 "生产模式",您可以使用 composer run development-disable