-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logger): implement slog.Handler (#13)
* feat(logger): implement slog.Handler This implements slog.Handler interface. You can use Log as an slog handler. * feat: compile for go1.20 and go1.21 * refactor: match log/slog level values * feat: add slog tests * chore: downgrade the minimum go version to go1.19 * doc: add slog support * refactor: rename files * fix: add emoji test * chore!: change default timestamp and level key names * fix: lint
- Loading branch information
1 parent
d96bea2
commit de79c17
Showing
21 changed files
with
454 additions
and
108 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
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
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,15 @@ | ||
//go:build go1.21 | ||
// +build go1.21 | ||
|
||
package log | ||
|
||
import "log/slog" | ||
|
||
// fromSlogLevel converts slog.Level to log.Level. | ||
var fromSlogLevel = map[slog.Level]Level{ | ||
slog.LevelDebug: DebugLevel, | ||
slog.LevelInfo: InfoLevel, | ||
slog.LevelWarn: WarnLevel, | ||
slog.LevelError: ErrorLevel, | ||
slog.Level(12): FatalLevel, | ||
} |
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,15 @@ | ||
//go:build !go1.21 | ||
// +build !go1.21 | ||
|
||
package log | ||
|
||
import "golang.org/x/exp/slog" | ||
|
||
// fromSlogLevel converts slog.Level to log.Level. | ||
var fromSlogLevel = map[slog.Level]Level{ | ||
slog.LevelDebug: DebugLevel, | ||
slog.LevelInfo: InfoLevel, | ||
slog.LevelWarn: WarnLevel, | ||
slog.LevelError: ErrorLevel, | ||
slog.Level(12): FatalLevel, | ||
} |
Oops, something went wrong.