added iso format for log ts

This commit is contained in:
Matt Johnstone 2024-10-25 10:38:15 +02:00
parent 14eab970db
commit 888d065acf
No known key found for this signature in database
GPG Key ID: BE985FBB9BE7D3BB
2 changed files with 11 additions and 1 deletions

View File

@ -53,6 +53,10 @@ type SolanaCollector struct {
NodeFirstAvailableBlock *GaugeDesc NodeFirstAvailableBlock *GaugeDesc
} }
func init() {
slog.Init()
}
func NewSolanaCollector( func NewSolanaCollector(
provider rpc.Provider, slotPace time.Duration, balanceAddresses, nodekeys, votekeys []string, identity string, provider rpc.Provider, slotPace time.Duration, balanceAddresses, nodekeys, votekeys []string, identity string,
) *SolanaCollector { ) *SolanaCollector {

View File

@ -2,13 +2,19 @@ package slog
import ( import (
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore"
) )
var log *zap.SugaredLogger var log *zap.SugaredLogger
// Init initializes the logger // Init initializes the logger
func Init() { 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() log = logger.Sugar()
} }