-
Notifications
You must be signed in to change notification settings - Fork 321
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
init default logger #495
init default logger #495
Conversation
Can this be filtered by an env variable? I think that is really a requirement to enabling this by default, especially having a way to make it only log things inside my app or just tide, not all dependencies. |
@dignifiedquire still working on adding filtering on the |
b341b5a
to
f753311
Compare
In reply to the question of whether logging should be integrated: For a production logger, I think there'll be a lot more API surface area, possibly justifying splitting this out into an independent crate (even if it's included by a default Other features people might reasonably eventually expect from a feature-complete local logger: Log rotation, configurable formats, splitting into different files depending on a predicate like status code (similar to nginx's approach to logging), parameter filtering. It would be really nice if the default logger were able to support stuff like that, so that the path from development to production wouldn't be "replace the tide logger" but instead "configure the tide logger." |
@jbr I love this phrasing and agree that is indeed the way we should be thinking of driving this feature. As such I probably should add some more context for this logger specifically, explaining the ideas behind it, the direction it's going, and shortcomings it has. The idea behind Because However some things we indeed do not support yet; in particular redaction seems important. Maybe the right approach here is to have Hopefully this sheds some light on what [1]: We probably should do tty detection here as well. edit: something I forgot to mention is just how fast ndjson is -- as of 2020 it can be parsed at a rate that's nearing disk read speeds (~2-4 x 2.5gb/s). The chances overall of this ever being a performance bottleneck seem fairly slim. |
I should have looked more into femme before commenting, that's really cool! I saw the pretty-printed output in the screenshot and assumed that it was just logging unstructured text, but the ability to repurpose pino's utilities (and transporters!) makes this approach way more feature-complete and production ready than I understood. |
@jbr no worries; I understand the confusion and felt it was on me to share more details here heh 😅 |
Cargo.toml
Outdated
mime_guess = "2.0.3" | ||
femme = { path = "../../femme" } |
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'd like to try it out. Can you post which version of femme
is used?
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.
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.
When I build the app with the release flag the logs look like
{"level":30,"time":1589717147052,"msg":"--> Response sent","method":"\"GET\"","status":"200","duration":"\"157ms\"","path":"\"/api/v1/users\""}
the string (of key: value, not the message) have also the double quotes escaped. Is that intended?
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.
@isgj that's definitely not expected and we should fix that. Filed lrlna/femme#12 on femme. Thanks for reporting!
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.
Okay, this will require patching the log
crate. I don't think we should block adding this feature on that, even if it might be worth fixing in either femme or tide for the time being.
Filed an issue on |
Relies on lrlna/femme#9. Adds a default logger that supports
log
's key-value API. A base "hello world" example now looks like this:There's a bit of a design question whether we should expose this as a separate function, or integrate it directly into the framework. I think logging is kind of on the fringe here since it not only captures things going on inside the framework; it captures things going on outside of it as well.
I feel that making it a single line to enable logging strikes a good balance between the two -- we make it easy to get a good setup going with minimal work, but we don't enable things that have global implications for the program without consulting the user.
Screenshots