Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logger] Allow to add processors to monolog #474

Closed
wodor opened this issue Nov 25, 2021 · 4 comments · Fixed by #506
Closed

[Logger] Allow to add processors to monolog #474

wodor opened this issue Nov 25, 2021 · 4 comments · Fixed by #506

Comments

@wodor
Copy link

wodor commented Nov 25, 2021

Description

Currently LogFactory just returns one processor (

return [new PsrLogMessageProcessor()];
)
I guess the way is to replace it in my application, but it looks like it is not easy to do because it is embedded in MonologBootloader https://github.com/spiral/framework/blob/2.8/src/Bridge/Monolog/src/Bootloader/MonologBootloader.php
So I need to "duplicate" that code too.

Example

It would be great to be able to define processors to add in a bootloader and have the constructor of implementation of LogsInterface that accepts a collection of processors.

@wodor wodor added the Feature label Nov 25, 2021
@butschster
Copy link
Member

Sounds good! Thank you!

@wodor
Copy link
Author

wodor commented Nov 25, 2021

I am willing to work on a solution for this, it would be best if I get some direction from the authors.

@butschster
Copy link
Member

I think processors could be migrated to MonologConfig like handlers.

@butschster
Copy link
Member

butschster commented Feb 2, 2022

Hi @wodor! Could you check PR #506?

We have added the ability to configure channel processors via config:

// config monolog.php

<?php

declare(strict_types=1);

use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;

return [
    'globalLevel' => Logger::DEBUG,

    'handlers' => [
        'stdout' => [
            [
                'class' => \Monolog\Handler\SyslogHandler::class,
                'options' => [
                    'ident' => 'app',
                    'facility' => LOG_USER,
                ]
            ]
        ],
    ],
    'processors' => [
        'stdout' => [
            [
                'class'   => PsrLogMessageProcessor::class,
                'options' => [
                    'dateFormat' => 'c'
                ]
            ],
        ],
    ]
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants