-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging: Automatic wrap
default for filter
encoder
#5980
Conversation
92552e1
to
41bcc5b
Compare
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.
Thank you very much Francis! This will help improving Mercure default config.
3532472
to
2688614
Compare
2688614
to
3f7342d
Compare
Thanks for working on this! Yuck 馃槣 Likely to accept, but first, @dunglas Can you help me see the config difference for Mercure, before and after this change? I'm mainly curious so I can understand the impact here. |
Ah right, I'll add an adapt test to show the difference. |
Currently: https://github.com/dunglas/mercure/pull/862/files Hopefully, after, the same config in both files, automatically adapting to console or json depending on if run in TTY mode or not:
|
Gotcha, so it allows you to remove the |
Correct. |
Co-authored-by: K茅vin Dunglas <kevin@dunglas.fr>
Co-authored-by: K茅vin Dunglas <kevin@dunglas.fr>
Co-authored-by: K茅vin Dunglas <kevin@dunglas.fr>
3f7342d
to
a20dbef
Compare
Added a test, ready to go IMO. |
Oh lmao, @dunglas' review from last month was enough to allow it to get merged 馃槀 I didn't expect that a review from before he was granted collaborator status would be valid for that. Fun detail of github I guess! |
ohhh, lol, that's fun -- so reviews are retroactive in granting merge permissions. That's neat. |
I was talking with @dunglas and he pointed out how awkward it is to have to configure
wrap
on thefilter
encoder because it loses the nice-to-have default behaviour of checking ifstderr
is a terminal to choose a default ofconsole
vsjson
.Getting this to work just right was quite messy, but I think I got it working well now. I also made some adjustments that may or may not be considered breaking changes for some people, since we're changing some default behaviour for the
filter
encoder, and I slightly changed the logic for detecting the terminal.stderr
is a terminal instead ofstdout
because our default writer isstderr
anyway, it was kinda incorrect to be checkingstdout
I thinkwriter
wasn't considered when determining the default encoder; this meant that if aoutput file foo.log
was configured and it was run at a terminal, it would writeconsole
logs to the file by default (but with color turned off). That's a bad default, it should be writingjson
to the file even when run as a terminal unless otherwise stated.wrap
is no longer required forfilter
encoder, it now defaults tojson
whenstderr
is not a terminal, andconsole
when it is a terminalwriter
module to the configuredencoder
if it has theConfiguresFormatterDefault
interface, which is called immediately after provisioning as a 2nd phase in provisioningfilter
encoder implements that interface, and uses it to check if the writer is a terminal, switching the nested encoder toconsole
; it also passes down the writer if the explicitly configured encoder if itself wants the writer (e.g. filter inside filter, or whatever).