monolog:
    channels:
        - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists

when@dev:
    monolog:
        handlers:
            main:
                type: stream
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug
                channels: [ "!event", "!deprecation", "!doctrine" ]
            # Activate this channel if needed for debug
            # deprecation:
            #     type: rotating_file
            #     path: '%kernel.logs_dir%/deprecations.%kernel.environment%.log'
            #     max_files: 1
            #     channels: [ "deprecation" ]
            # doctrine:
            #     type: rotating_file
            #     path: '%kernel.logs_dir%/doctrine.%kernel.environment%.log'
            #     max_files: 1
            #     channels: [ "doctrine" ]
            console:
                type: console
                process_psr_3_messages: false
                channels: [ "!event", "!doctrine", "!console", "!deprecation" ]

when@test:
    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: nested
                excluded_http_codes: [ 404, 405 ]
                channels: [ "!event" ]
            nested:
                type: stream
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug

when@prod: &prod
    monolog:
        handlers:
            main:
                type: fingers_crossed
                channels: [ "!deprecation" ] # Channels are ignored in nested handlers so we need to define them here (see https://github.com/symfony/monolog-bundle/issues/375)
                action_level: error
                handler: nested
                excluded_http_codes: [ 404, 405 ]
                buffer_size: 50 # How many messages should be saved? Prevent memory leaks
            nested:
                type: rotating_file
                max_files: 30
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug
            console:
                type: console
                process_psr_3_messages: false
                channels: [ "!event", "!doctrine" ]

when@preprod: *prod