config: pad log level
longest that can be created is DPANIC, or 6 wide. Upstream-Ref: https://github.com/uber-go/zap/blob/v1.24.0/zapcore/level.go#L135
This commit is contained in:
parent
5f53e60ace
commit
be92e2c705
|
@ -8,6 +8,7 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -36,7 +37,9 @@ func initLogger(ll string) *zap.Logger {
|
||||||
base.EncoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
base.EncoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
||||||
enc.AppendInt64(t.Unix())
|
enc.AppendInt64(t.Unix())
|
||||||
}
|
}
|
||||||
base.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
|
base.EncoderConfig.EncodeLevel = func(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder) {
|
||||||
|
enc.AppendString(fmt.Sprintf("%-6s", l.CapitalString()))
|
||||||
|
}
|
||||||
base.EncoderConfig.ConsoleSeparator = " "
|
base.EncoderConfig.ConsoleSeparator = " "
|
||||||
base.DisableCaller = true
|
base.DisableCaller = true
|
||||||
return zap.Must(base.Build())
|
return zap.Must(base.Build())
|
||||||
|
|
Loading…
Reference in New Issue