Skip to content
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

Add context to logger #1542

Draft
wants to merge 1 commit into
base: release-branch.v7
Choose a base branch
from

Conversation

olivere
Copy link
Owner

@olivere olivere commented Oct 14, 2021

This commit adds a LoggerWithContext interface that extends the
Logger interface by a method PrintfWithContext that, when
implemented, is called instead of the Printf method of the Logger
interface.

The purpose of PrintfWithContext is to receive the current context
under which the logging happens. Notice that this doesn't always
have to be request-scoped, i.e. an actual API call from a user. It may
also be from an internal state or process, e.g. Bulk processor or node
health.

Close #1541

@olivere olivere added this to the 7.0.30 milestone Oct 14, 2021
This commit adds a `LoggerWithContext` interface that extends the
`Logger` interface by a method `PrintfWithContext` that, when
implemented, is called instead of the `Printf` method of the `Logger`
interface.

The purpose of `PrintfWithContext` is to receive the current context
under which the logging happens. Notice that this doesn't always
have to be request-scoped, i.e. an actual API call from a user. It may
also be from an internal state or process, e.g. Bulk processor or node
health.

Close #1541
@olivere olivere force-pushed the add-context-logger.issue-1541 branch from d01a467 to debed67 Compare October 14, 2021 16:12
@olivere olivere mentioned this pull request Oct 14, 2021

// LoggerWithContext extends the Logger interface by a context.
type LoggerWithContext interface {
Logger

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think about LoggerWithContext implements Logger interface is necessarily.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise you can’t specify the logger in a backwards compatible manner with SetErrorLog etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right :)

@olivere olivere modified the milestones: 7.0.30, 7.0.31 Dec 17, 2021
@olivere olivere modified the milestones: 7.0.31, 7.0.32 Jan 7, 2022
@olivere olivere modified the milestones: 7.0.32, 7.0.33 Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logger with context ?
2 participants