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

Handlers that require complex constructor arguments (RavenHandler) fail #30

Closed
dmnc opened this issue Jul 29, 2015 · 1 comment
Closed
Milestone

Comments

@dmnc
Copy link
Contributor

dmnc commented Jul 29, 2015

I might be missing something here, but I don't seem to be able to use the closure system on constructor arguments, only on setters.

This seems to indicate that for something like the RavenHandler where I need to pass a Raven_Client I am pretty stuck.

It looks like the RedisHandler would have the same problem.

@rantonmattei
Copy link
Contributor

Yes, you are absolutely right. There are still a few things missing. What you are mentioning is part of it.

I referenced that in a blog post I wrote. https://medium.com/orchard-technology/enhancing-monolog-699efff1051d (See Limitations section). I should probably add that to the ReadMe as well cause it impacts a bunch of handlers.

I haven't given it too much thoughts yet but feel free to take a stab at it and submit a PR.

The main challenge here is to be able to translate a statement like

new Raven_Client($someArg, $anotherArg, ...);

into something much simpler like a Yaml syntax and to have it flexible enough so it does support instantiating any classes passing a bunch of args.

Something along

handlers:
    raven_handler:
        class: Monolog\Handler\RavenHandler
        raven_client:
            class: Raven_Client
            options_or_dsn: "xxx"
        level: WARNING

would be ideal and would allow to reuse the class loader. It would require adding more recursion to the parsing. (=> This is just a quick thought.)

For now the only workaround I see is to use a Php array as your config. I haven't tried though, but it might work.

I'll leave this issue open in case someone wants to take a stab at it.

@rantonmattei rantonmattei added this to the 0.3.0 milestone Jul 31, 2015
rantonmattei added a commit that referenced this issue Aug 24, 2015
Got rid of the Limitation section as issue #30 has been resolved
rantonmattei added a commit to rantonmattei/monolog-cascade that referenced this issue Aug 24, 2015
Got rid of the Limitation section as issue theorchard#30 has been resolved

Update README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants