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 WithOptions() for SugaredLogger #1072

Closed
e-nikolov opened this issue Mar 25, 2022 · 4 comments · Fixed by #1079
Closed

Add WithOptions() for SugaredLogger #1072

e-nikolov opened this issue Mar 25, 2022 · 4 comments · Fixed by #1079

Comments

@e-nikolov
Copy link

e-nikolov commented Mar 25, 2022

Currently there is WithOptions() only for unsugared loggers, so Desugar() and then Sugar() needs to be called in order to add options to a SugaredLogger.

@abhinav
Copy link
Collaborator

abhinav commented Mar 30, 2022

Hey @e-nikolov!
This is a reasonable request.
We'll be happy to review a PR for this.

@craigpastro
Copy link
Contributor

Happy to give this a shot if that is okay?

@abhinav
Copy link
Collaborator

abhinav commented Apr 8, 2022

Happy to give this a shot if that is okay?

Oops, I missed this @craigpastro. Sure! Feel free to create a PR for this.

@craigpastro
Copy link
Contributor

Thanks! Created a PR.

abhinav pushed a commit that referenced this issue Apr 8, 2022
Add a WithOptions method to SugaredLogger that allows specifying
building a copy of the logger with the specified options applied.

This allows turning,

    slog.Desugar().WithOptions(...).Sugar()

Into,

    slog.WithOptions(...)

Closes #1072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants