-
Notifications
You must be signed in to change notification settings - Fork 6
Add logger plugin #8
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the promise is handling the throwing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by catching the exception, i mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes when calling one of the callable passed to the then method, if it returns something then the value will go into the next onFulfilled callable, if it throw an exception it will go into the next onRejected callable.
i think it would make sense to have an own thing for that. did you know https://github.com/namshi/cuzzle ? something like this for PSR-7 would be really cool. i would create a RequestFormatter and ResponseFormatter interface in the utils and implement it with a StringFormatter for now. and later we can do the curl plugin. the formatters would have just one method |
Do we really need this? I mean, the nornalizer could work (probably in the utils repo), but in case of Monolog for example, we could have a Monolog Formatter. The point is that it is not really the plugin's responsibility IMHO. Haven't know cuzzle before, but it's great. |
yeah, i really love the idea of formatting a log so you can simply paste it on the cli to see what that request returned. |
yeah, formatting belongs into utils. except the monolog (or maybe psr log?) normalizing, because that is specific to the task of logging. i think a formatter should return only string, not mixed or string|array, it would make little sense. we can also have an array normalizer in utils if we think there are other use cases, but i would not implement the Formatter interface with that. |
Actually we could even format it to plain HTTP, so that we can directly send it with local testing clients. I think request/response formatter interfaces should go into a separate package. With some basic implementations. Also, formatters should always format to string I think. |
The logger plugin should probably not require the formatter to be injected. The underlying PSR3 implementation should provide a way to add custom formatters. Not sure if it is possible though. |
The logger plugin should probably not require the formatter to be
injected. The underlying PSR3 implementation should provide a way to add
custom formatters. Not sure if it is possible though.
for the message, we need a formatter i think. but for the context i
agree that we should try to push that to the logger and just pass the
object, as we do with the $exception.
I think request/response formatter interfaces should go into a separate
package. With some basic implementations. Also, formatters should always
format to string I think.
not sure if we need a separate package for that. imho utils is a good
place for this. its a psr 7 utility to format requests and responses as
strings.
|
I have a feeling that this utils repo will eventually get a bit fat. Also, I imagine the utils repo as a collection of utilities for httplug and clients. Putting too much stuff in it is not a good idea IMO. We could have a psr7-utils repo for strictly PSR-7 utilities, without Httplug and other client related stuff in it. |
i am more afraid of too many repositories than of that thing becoming
too fat. but i can see your reasoning. having several X-utils
repositories sounds confusing too. lets make it a psr7-formatter
repository then. that way its clear what its about.
oh, or does something like that already exist?
|
psr7-utils, httplug-utils....I can't imagine more utils for now.
Thinking about this: Maybe a psr7-utils package would be good, because there can be several cases when we just want one small psr7 thing to be somewhere. So a common psr7-utils repo could mitigate this problem.
Don't think so, at least I don't know about it. |
fine for me.
for the question whether there are existing tools, i asked the internets
https://twitter.com/dbu/status/665090150339321856
|
The Formatter thing in ivory http adapter was also used for that : https://github.com/egeloen/ivory-http-adapter/blob/master/src/Event/Formatter/Formatter.php |
So to make it short on the changes :
Ok for everyone ? @dbu @sagikazarmark |
agreed. but the Normalizer should have an |
👍 |
898c284
to
908f761
Compare
spec/LoggerPluginSpec.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this begs the question: logs...what?
I have moved normalizer to |
Nice job @joelwurtz |
Actually don't know if this "normalizer" should be in the plugins library, WDYT ?