-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Logging improvements #2931
Logging improvements #2931
Conversation
…ix typo on server_logger.
…g to sanic.websockets.
… on server shutdownm with incoming connections;
… Access log doesn't need level printed either.
…work ir not reversal.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2931 +/- ##
=============================================
- Coverage 87.985% 87.626% -0.360%
=============================================
Files 94 101 +7
Lines 7408 7597 +189
Branches 1307 1328 +21
=============================================
+ Hits 6518 6657 +139
- Misses 599 644 +45
- Partials 291 296 +5 ☔ View full report in Codecov by Sentry. |
What's the reason for removing the timestamp? I personally find it useful while developing - helps spotting slow bits of code and correlating events between systems/apps (for example if you have a webserver and a background worker). |
@prryplatypus Muddies up the logs more than necessary if not needed. If it is needed, it is not so difficult to get the timestamps: from sanic.log import LOGGING_CONFIG_DEFAULTS
LOGGING_CONFIG_DEFAULTS['formatters']['generic']['class'] = 'sanic.logging.formatter.ProdFormatter' Perhaps we could make it all even simpler with config values on the Sanic app. Something like: app.config.LOG_FORMATTER = "sanic.logging.formatter.ProdFormatter" FWIW, uvicorn doesn't even give you timestamps on access logs. |
I'd be happy with just time 👀 |
…o logging-improvements
This replaces the nice work that @Tronic did on #2852 to include debug and prod style logging, as well as a legacy formatter to allow for backwards compat logging for some period of time.
Debug logging
Prod logging (w/ access logs explicitly on)
As you can see the main difference is just in the usage of the timestamp. We skip it in Debug (except for access logs).