symfony / monolog-bundle

Symfony Monolog Bundle
symfony.com
MIT License
2.89k stars 230 forks source link

Allow to add processors via configuration #104

Closed kingcrunch closed 5 years ago

kingcrunch commented 10 years ago

Monolog and the Monolog-bridge come with some pre-defined processors to use. It would be nice, if one could enable them easily via configuration, like

monolog:
  handlers: ~ # define your handlers here (omitted)
  processors:
    foo:
      type: memory_peak_usage
      real_usage: true
      use_formatting: false
      channels: [bar, baz]
    bar:
      type: psr_log_message
      handlers: [mainfile]
gerryvdm commented 9 years ago

:+1:

nicolas-san commented 9 years ago

Edit : appears to be french translation error, in english doc there is no section processors

In the http://symfony.com/fr/doc/current/reference/configuration/monolog.html you have :

   # Exemples:
  syslog:
       type:                stream
       path:                /var/log/symfony.log
       level:               ERROR
       bubble:              false
       formatter:           my_formatter
       processors:
           - some_callable

With processors, but :

Unrecognized options "processors" under "monolog.handlers.syslog" when I try to use it, and after a quick search no trace of "processors" in https://github.com/symfony/MonologBundle/blob/master/DependencyInjection/Configuration.php

nicoschoenmaker commented 9 years ago

It took me a while to find that the current solution to make monolog PSR-3 compatible was to add:

monolog.processor.psr_log_message_processor:
    class: Monolog\Processor\PsrLogMessageProcessor
    tags:
        - { name: monolog.processor }

But this feels too complicated to me, so :+1: for this issue (or for making the PsrLogMessageProcessor a default processor).

lyrixx commented 5 years ago

With Symfony 3.4+ with autoconfiguration, and #285, processors added to an application will be automatically registred. So Now it's really super easy to add a processor to monolog. That's why I'm closing this issue.