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

proposal: log/slog: Log should have a context free variant #64456

Closed
3052 opened this issue Nov 30, 2023 · 0 comments
Closed

proposal: log/slog: Log should have a context free variant #64456

3052 opened this issue Nov 30, 2023 · 0 comments
Labels
Milestone

Comments

@3052
Copy link

3052 commented Nov 30, 2023

Proposal Details

currently I want to use these:

func Debug(msg string, args ...any)
func Error(msg string, args ...any)
func Info(msg string, args ...any)
func Warn(msg string, args ...any)

which all have variants with a context:

func DebugContext(ctx context.Context, msg string, args ...any)
func ErrorContext(ctx context.Context, msg string, args ...any)
func InfoContext(ctx context.Context, msg string, args ...any)
func WarnContext(ctx context.Context, msg string, args ...any)

but the default four are not enough for my needs. I need something beyond Debug like Trace. so I found this:

func Log(ctx context.Context, level Level, msg string, args ...any)

but its quite different. it requires a context. I would have thought the API would have looked like this instead:

func Log(level Level, msg string, args ...any)
func LogContext(ctx context.Context, level Level, msg string, args ...any)

I suppose its too late to change it at this point, but maybe we could add something like this:

func LogLevel(level Level, msg string, args ...any)
@3052 3052 added the Proposal label Nov 30, 2023
@mauri870 mauri870 changed the title log/slog: Log should have a context free variant proposal: log/slog: Log should have a context free variant Nov 30, 2023
@gopherbot gopherbot added this to the Proposal milestone Nov 30, 2023
@3052 3052 closed this as completed Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

2 participants