From 888d065acfe29ee6cb4846f00ced89891bdfaf4a Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Fri, 25 Oct 2024 10:38:15 +0200 Subject: [PATCH] added iso format for log ts --- cmd/solana_exporter/exporter.go | 4 ++++ pkg/slog/main.go | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/solana_exporter/exporter.go b/cmd/solana_exporter/exporter.go index 0ef6298..4d46836 100644 --- a/cmd/solana_exporter/exporter.go +++ b/cmd/solana_exporter/exporter.go @@ -53,6 +53,10 @@ type SolanaCollector struct { NodeFirstAvailableBlock *GaugeDesc } +func init() { + slog.Init() +} + func NewSolanaCollector( provider rpc.Provider, slotPace time.Duration, balanceAddresses, nodekeys, votekeys []string, identity string, ) *SolanaCollector { diff --git a/pkg/slog/main.go b/pkg/slog/main.go index 57809f3..24257bf 100644 --- a/pkg/slog/main.go +++ b/pkg/slog/main.go @@ -2,13 +2,19 @@ package slog import ( "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) var log *zap.SugaredLogger // Init initializes the logger func Init() { - logger, _ := zap.NewProduction() + config := zap.NewProductionConfig() + + // Configure the encoder to use ISO8601 time format + config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + + logger, _ := config.Build() log = logger.Sugar() }