change format to something like symfony monolog

This commit is contained in:
Pavel 2024-04-17 11:42:31 +03:00
parent f6c319752e
commit 7c784c8310

View File

@ -42,17 +42,17 @@ func EncoderConfigConsole() zapcore.EncoderConfig {
return zapcore.EncoderConfig{ return zapcore.EncoderConfig{
MessageKey: "message", MessageKey: "message",
LevelKey: "level", LevelKey: "level",
TimeKey: "timestamp", TimeKey: "datetime",
NameKey: "logger", NameKey: "logger",
CallerKey: "caller", CallerKey: "caller",
FunctionKey: zapcore.OmitKey, FunctionKey: zapcore.OmitKey,
StacktraceKey: "", StacktraceKey: "",
LineEnding: "\n", LineEnding: "\n",
EncodeLevel: func(level zapcore.Level, encoder zapcore.PrimitiveArrayEncoder) { EncodeLevel: func(level zapcore.Level, encoder zapcore.PrimitiveArrayEncoder) {
encoder.AppendString("level=" + level.CapitalString()) encoder.AppendString("level_name=" + level.CapitalString())
}, },
EncodeTime: func(t time.Time, encoder zapcore.PrimitiveArrayEncoder) { EncodeTime: func(t time.Time, encoder zapcore.PrimitiveArrayEncoder) {
encoder.AppendString("time=" + t.Format(time.RFC3339)) encoder.AppendString("datetime=" + t.Format(time.RFC3339))
}, },
EncodeDuration: zapcore.StringDurationEncoder, EncodeDuration: zapcore.StringDurationEncoder,
EncodeCaller: func(caller zapcore.EntryCaller, encoder zapcore.PrimitiveArrayEncoder) { EncodeCaller: func(caller zapcore.EntryCaller, encoder zapcore.PrimitiveArrayEncoder) {
@ -85,8 +85,8 @@ func NewZapJSON(debug bool) *zap.Logger {
func EncoderConfigJSON() zapcore.EncoderConfig { func EncoderConfigJSON() zapcore.EncoderConfig {
return zapcore.EncoderConfig{ return zapcore.EncoderConfig{
MessageKey: "message", MessageKey: "message",
LevelKey: "level", LevelKey: "level_name",
TimeKey: "timestamp", TimeKey: "datetime",
NameKey: "logger", NameKey: "logger",
CallerKey: "caller", CallerKey: "caller",
FunctionKey: zapcore.OmitKey, FunctionKey: zapcore.OmitKey,