forked from ko-build/ko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce go-logr to allow injecting loggers
This change adds a dependency on `go-logr/logr` and replaces all uses of the `log` package from Go's standard library with a `logr`-based implementation. To ease the transition, and to keep the diff small, this change introduces a package `github.com/google/ko/pkg/log` that should be imported in place of `log` from the standard library. The new package provides some of the same functions as `log`, e.g., `Printf()` and `Fatalf()`. The replacement functions takes an extra `context.Context` argument. The `Context` is used to look up the `logr.Logger` to use for logging. Existing log statements have been updated to use the transition functions, with `Context` plumbed through where required. New code can use the new logging syntax, e.g.: ```go log.L(ctx).Info("something interesting happened", "key", "value") ``` or ```go log.L(ctx).Error(err, "uh oh", "what", "snafu") ``` This change alters the log output to `logr`'s structured output, with named fields for the log message and level. As an example, a log line that previously looked like this: ``` 2022/01/25 19:44:18 Building github.com/google/ko/test for linux/amd64 ``` Will look like as follows with this change: ``` 2022/01/25 19:46:02 ko: "level"=1 "msg"="Building github.com/google/ko/test for linux/amd64" ``` Fixes: ko-build#560 Related: ko-build#542
- Loading branch information
Showing
34 changed files
with
1,481 additions
and
95 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
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.