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

Using a custom handler with a nested handler #480

Open
gturri opened this issue Apr 22, 2024 · 0 comments
Open

Using a custom handler with a nested handler #480

gturri opened this issue Apr 22, 2024 · 0 comments

Comments

@gturri
Copy link

gturri commented Apr 22, 2024

Hi,

first of all, thanks for this great piece of software!

I'm trying to define a custom handler which should do some filtering on the LogRecord and then forward some of those to a nested handler. I've spent a couple hours on it, and I'm not sure if I'm missing something or if it's not possible yet.

In some more details:
I've seen the issue #206 which is similar to what I'm trying to achieve, and I subsequently see that I can put

type: service
id: my_handler

in order to reference my class.

But I don't understand if (and how) I can reference a nested handler.

Said differently, what I would like to have is a conf similar to the crossed_finger one; ie, like

monolog:
  handlers:
    my_handler:
      type: service
      id: my_handler
      handler: file
    file:
      type: rotating_file

When I read the code of buildHandler I have the feeling that it is not possible. (Unless if it has something to do with the nested config (I'm afraid I don't really understand what that does)).

So my questions are:

  1. Am I missing something; Is the feature I'm looking for already available?
  2. Or, if it is not possible, would you be open to adding it? (in which case I could try to propose a pull request if we can agree on an approach. I guess I should copy what is done for the finger_crossed handler, but I'm afraid there may not be a generic way to inject some nested handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant