refactor(log): disable coloring in testing logger (#22466)
This commit is contained in:
parent
f6c7ab68e7
commit
ffa74d17cb
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -855,7 +855,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.20"
|
||||
go-version: "1.21"
|
||||
check-latest: true
|
||||
cache: true
|
||||
cache-dependency-path: log/go.sum
|
||||
|
||||
@ -22,10 +22,11 @@ Each entry must include the Github issue reference in the following format:
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Improvements
|
||||
## [v1.5.0](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.4.1) - 2024-11-07
|
||||
|
||||
* [#22233](https://github.com/cosmos/cosmos-sdk/pull/22233) Use sonic json library for faster json handling
|
||||
* [#22347](https://github.com/cosmos/cosmos-sdk/pull/22347) Add cosmossdk.io/log/slog to allow using a standard library log/slog-backed logger.
|
||||
* [#22466](https://github.com/cosmos/cosmos-sdk/pull/22466) Disable coloring in testing logger.
|
||||
* [#22233](https://github.com/cosmos/cosmos-sdk/pull/22233) Use sonic json library for faster json handling.
|
||||
* [#22347](https://github.com/cosmos/cosmos-sdk/pull/22347) Add `cosmossdk.io/log/slog` to allow using a standard library log/slog-backed logger. This required to bump the minimum go version of `cosmossdk.io/log` to 1.21.
|
||||
|
||||
## [v1.4.1](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.4.1) - 2024-08-16
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module cosmossdk.io/log
|
||||
|
||||
go 1.20
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.12.3
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package log
|
||||
|
||||
import "github.com/rs/zerolog"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// TestingT is the interface required for logging in tests.
|
||||
// It is a subset of testing.T to avoid a direct dependency on the testing package.
|
||||
@ -39,15 +43,18 @@ func NewTestLoggerError(t TestingT) Logger {
|
||||
}
|
||||
|
||||
func newTestLogger(t TestingT, lvl zerolog.Level) Logger {
|
||||
cw := zerolog.NewConsoleWriter()
|
||||
cw.Out = zerolog.TestWriter{
|
||||
T: t,
|
||||
// Normally one would use zerolog.ConsoleTestWriter
|
||||
// to set the option on NewConsoleWriter,
|
||||
// but the zerolog source for that is hardcoded to Frame=6.
|
||||
// With Frame=6, all source locations are printed as "logger.go",
|
||||
// but Frame=7 prints correct source locations.
|
||||
Frame: 7,
|
||||
cw := zerolog.ConsoleWriter{
|
||||
NoColor: true,
|
||||
TimeFormat: time.Kitchen,
|
||||
Out: zerolog.TestWriter{
|
||||
T: t,
|
||||
// Normally one would use zerolog.ConsoleTestWriter
|
||||
// to set the option on NewConsoleWriter,
|
||||
// but the zerolog source for that is hardcoded to Frame=6.
|
||||
// With Frame=6, all source locations are printed as "logger.go",
|
||||
// but Frame=7 prints correct source locations.
|
||||
Frame: 7,
|
||||
},
|
||||
}
|
||||
return NewCustomLogger(zerolog.New(cw).Level(lvl))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user