You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
This is a placeholder issue to replace the current usage (and references) of uber-go/zap with standard library's log/slog package. This allows a standard logging API for any Go application, where different implementations of its slog.Handler interface focus on actually registering the log events in the appropriate backend or target output.
Note: Log levels in log/slog range from Debug to Error, so any Fatal-level log entries should be replaced with Error-level ones, followed by an os.Exit(1), if that is really the desired behavior
Describe the solution you'd like
The generated internal/log package contains new logic to create a log/slog logger instead of a uber-go/zap one.
The generated go.mod file no longer references uber-go/zap
All logger and logging references are replaced with log/slog equivalents
Suggestion:
use log/slog's Attr (slog.String, slog.Bool, etc) functions when passing attributes to log events. This keeps the key-value pairs in the attributes neatly organized, as well as leveraging the package's proposed strongly-typed attributes
Describe alternatives you've considered
N/A - the standard library inclusion means that it should be used as a common (structured) logging API for Go applications. This doesn't mean that consumers of slog are tied to it completely -- its slog.Handler interface allows custom handling of the log events, so that custom behavior is still possible by calling slog.New with a custom slog.Handler.
Search
I did search for other open and closed issues before opening this.
Code of Conduct
I agree to follow this project's Code of Conduct
Additional context
No response
The text was updated successfully, but these errors were encountered:
You could have also closed mine, this one is way more detailed 😄
The only difference to my proposal is that I proposed to remove internal/log completely, as slog does not need a wrapper.
We could initialize the slog handler / logger directly in the entry point, I guess (just a single line of code).
Is your feature request related to a problem? Please describe.
This is a placeholder issue to replace the current usage (and references) of
uber-go/zap
with standard library'slog/slog
package. This allows a standard logging API for any Go application, where different implementations of itsslog.Handler
interface focus on actually registering the log events in the appropriate backend or target output.Describe the solution you'd like
internal/log
package contains new logic to create alog/slog
logger instead of auber-go/zap
one.uber-go/zap
log/slog
equivalentsSuggestion:
log/slog
's Attr (slog.String
,slog.Bool
, etc) functions when passing attributes to log events. This keeps the key-value pairs in the attributes neatly organized, as well as leveraging the package's proposed strongly-typed attributesDescribe alternatives you've considered
N/A - the standard library inclusion means that it should be used as a common (structured) logging API for Go applications. This doesn't mean that consumers of
slog
are tied to it completely -- itsslog.Handler
interface allows custom handling of the log events, so that custom behavior is still possible by callingslog.New
with a customslog.Handler
.Search
Code of Conduct
Additional context
No response
The text was updated successfully, but these errors were encountered: