-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This replaces the zap logging engine with Go 1.21's new structured logger, log/slog, or more precisely a thin wrapper around that ("xlog"). The log/slog package has a few things missing, which are present in xlog: 1. xlog provides a no-op logger, which simply discards any log output. This is extensively used in our tests. 2. xlog has a Fatal() output method, which simply calls Error() and then os.Exit(1). 3. xlog treats error values as first-class citizen. Since (log/slog).Error() is a convenience function for their default logger instance, there is no built-in way to treat errors as values. In comparison, (xlog).Error() constructs an slog.Attr, since xlog does not provide a default logger. Point (2) is debatable, since xlog.Fatal is only used in cmd/texd/main.go, so I'd be willing to forfeit it. Some TODOs remain: - xlog, i.e. its extension over log/slog, is not really tested - documentation is missing - the current xlog constructor (New) is a bit clunky to use, maybe switch to functional options? - some tests create a local buffer as log output target - this could be made easier with a `log, buf := xlog.NewBuffered()` constructor (albeit, the overhead is minimal) - for local development, I still like to have some colorization Issue: #1
- Loading branch information
Showing
32 changed files
with
369 additions
and
242 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
Oops, something went wrong.