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:
Paul Stemmet 2022-12-10 19:39:57 +00:00
parent 5f53e60ace
commit be92e2c705
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
1 changed files with 4 additions and 1 deletions

View File

@ -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())