geo6/mezzio-monolog

Mezzio Monolog ErrorHandler

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

This package is auto-updated.

Last update: 2024-03-22 15:36:34 UTC


README

Latest Stable Version Total Downloads Monthly Downloads Software License

This library enables Monolog as ErrorHandler in Mezzio.

Currently, there are 2 handlers supported (more will be added if needed):

Install

composer require geo6/mezzio-monolog

Configuration

Create a monolog.global.php file in your config directory:

<?php

declare(strict_types=1);

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

Usage

To enable it, you just have to add Geo6\Mezzio\Monolog\ConfigProvider::class to your main configuration (usually config/config.php):

...

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

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

...

The Monolog ErrorHandler will be active only in "production mode" (when $config['debug] is false).
To switch to "production mode", you can use composer run development-disable.