-
Notifications
You must be signed in to change notification settings - Fork 120
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
Try out using the new log/slog library for layered logging information #202
base: v2
Are you sure you want to change the base?
Conversation
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.
5ed76b7
to
fb74096
Compare
fb74096
to
1447c7b
Compare
ext/dispatcher.go
Outdated
@@ -143,7 +141,7 @@ func NewDispatcher(opts *DispatcherOpts) *Dispatcher { | |||
errHandler = opts.Error | |||
panicHandler = opts.Panic | |||
unhandledErrFunc = opts.UnhandledErrFunc | |||
errLog = opts.ErrorLog | |||
logger = opts.Logger |
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.
This is opinionated, but I find that having this type of helper function may help in some cases:
func iftrue[T any](cond bool, t T, f T) T {
if cond {
return t
}
return f
}
(addressing the lack of C-style ternary condition operator ?: in Go)
and then:
logger = iftrue(opts.Logger == nil, logger, opts.Logger)
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.
Ooh, I like that, thank you!
What
A few breaking changes to use the new
slog
packages. This will ultimately allow for customising the output format of any log output, thus integrating with existing solutions (and allowing for text/json/custom output), and potentially adding more debug information to the dispatcher logicImpact