-
Notifications
You must be signed in to change notification settings - Fork 362
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
Use logging.FromContext instead of logging.Default where possible #6312
Conversation
Loggers created using `logging.FromContext` include a request ID field, allowing readers to thread together actions performed for the same request. Also in future they allow us to add _additional_ fields, for example to distinguish S3 from lakeFS API operations deep inside the call tree. Fixes #2682.
This name is longer and more descriptive, to encourage using `logging.Default()`.
Not part of the same project, so missed by my LSP-based refactoring tools.
Reviewers, this one is probably easiest to discuss by commit:
|
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.
The adapter use of ctx for logging is great.
But renaming the Default() to ContextUnavailable() looks like we try to force the use of context why we ask for default logger.
Can we rename it back?
Yes, indeed! I really want to make it unpleasant to use a logger without providing a context. It is almost always correct to provide a context to get a logger. Would you be happier if I improved its godoc? |
No need to improve the godocs - approved. |
Thanks... pulling! I've been thinking about your idea. The point is that we already had |
Loggers created using
logging.FromContext
include a request ID field,allowing readers to thread together actions performed for the same request.
Also in future they allow us to add additional fields, for example to
distinguish S3 from lakeFS API operations deep inside the call tree.
Rename
logging.Default
to something more descriptive but perhaps lesspleasant, to encourage calling
logging.FromContext
.Fixes #2682.