-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Session configuration accepts slog handler to set up logging.
Discarding slog handler implemented and used instead of setting default slog logger. Checks on interval values added to Session constructor.
- Loading branch information
1 parent
294cf66
commit 57b9ffb
Showing
6 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package networking | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
) | ||
|
||
// TODO: Remove this file and the handler when the default [slog.DiscardHandler] will be introduced in | ||
// Go version 1.24. See https://go-review.googlesource.com/c/go/+/626486. | ||
|
||
// discardingHandler is a logger that discards all log messages. | ||
// It is used when no slog handler is provided in the [Config]. | ||
type discardingHandler struct{} | ||
|
||
func (h discardingHandler) Enabled(context.Context, slog.Level) bool { return false } | ||
func (h discardingHandler) Handle(context.Context, slog.Record) error { return nil } | ||
func (h discardingHandler) WithAttrs([]slog.Attr) slog.Handler { return h } | ||
func (h discardingHandler) WithGroup(string) slog.Handler { return h } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters