Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services

Home Page:https://seldaek.github.io/monolog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GroupHandler is missing FormattableHandlerInterface

jrantwijk opened this issue · comments

Monolog version 3

I'm currently getting the following error:

In FingersCrossedHandler.php line 240:
 The nested handler of type Monolog\Handler\WhatFailureGroupHandler does not support formatters

It seems like the parent GroupHandler class is missing the FormattableHandlerInterface.

commented

I recently stumbled across the same issue (also present in 2.x), but after trying to create a PR for this, I realised that we maybe have it backwards.

Somebody correct me if I'm wrong, but I think this works as intended. The FingersCrossedHandler is a wrapper that should not be used to wrap GroupHandlers but should wrap an AbstractProcessingHandler directly and "nest" the FingersCrossedHandler into the WhatFailureGroupHandler instead.

So a correct example configuration in yaml would be:

    monolog:
        handlers:
            main:
                type: whatfailuregroup
                members: [ nested ]
            nested:
                type: fingers_crossed
                action_level: error
                handler: stream
                excluded_http_codes: [ 404, 405 ]
            stream:
                type: stream
                path: "..."
                level: debug
                formatter: app.test_line_formatter

Right, or set the formatter directly on the correct handler and not trying to set it via the FingersCrossedHandler. It supports proxying if the nested handler is formattable but otherwise it fails to notify you of the misconfiguration.