Skip to content

Commit d43943b

Browse files
committed
Move logging time to RFC 3339
1 parent acd9ef7 commit d43943b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

agent/cmd/stack.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
_ "embed"
55
"fmt"
66
"os"
7+
"time"
78

89
"github.com/cortexapps/axon/common"
910
"github.com/cortexapps/axon/config"
@@ -13,6 +14,7 @@ import (
1314
"go.uber.org/fx"
1415
"go.uber.org/fx/fxevent"
1516
"go.uber.org/zap"
17+
"go.uber.org/zap/zapcore"
1618
)
1719

1820
func startAgent(opts fx.Option) {
@@ -36,6 +38,11 @@ var AgentModule = fx.Module("agent",
3638
cfg := zap.NewDevelopmentConfig()
3739
if os.Getenv("ENV") == "production" {
3840
cfg = zap.NewProductionConfig()
41+
cfg.EncoderConfig.TimeKey = "time"
42+
cfg.EncoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
43+
enc.AppendString(t.UTC().Format("2006-01-02T15:04:05.000Z"))
44+
}
45+
cfg.EncoderConfig.NameKey = "name"
3946
}
4047

4148
loggingLevel := zap.InfoLevel
@@ -48,7 +55,7 @@ var AgentModule = fx.Module("agent",
4855
if err != nil {
4956
panic(err)
5057
}
51-
return logger
58+
return logger.Named("axon")
5259
}),
5360
fx.Provide(cortexHttp.NewPrometheusRegistry),
5461
fx.Provide(createHttpTransport),

0 commit comments

Comments
 (0)