From 233f1c209942183693d714b0ec3c4c7c7d78f792 Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Thu, 15 Jan 2026 11:45:44 +0530 Subject: [PATCH] fix logging to have string based logs in place of json based logs --- common/logging.go | 22 ++++++++++++++++++++++ main.go | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 common/logging.go diff --git a/common/logging.go b/common/logging.go new file mode 100644 index 0000000..598ace7 --- /dev/null +++ b/common/logging.go @@ -0,0 +1,22 @@ +package common + +import ( + "os" + + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" +) + +// SetupLogging configures zerolog to output in string format instead of JSON. +func SetupLogging() { + log.Logger = log.Output(zerolog.ConsoleWriter{ + Out: os.Stderr, + TimeFormat: zerolog.TimeFieldFormat, + PartsOrder: []string{ + zerolog.TimestampFieldName, + zerolog.LevelFieldName, + zerolog.CallerFieldName, + zerolog.MessageFieldName, + }, + }) +} diff --git a/main.go b/main.go index a9feddb..0b42d7b 100644 --- a/main.go +++ b/main.go @@ -5,9 +5,11 @@ import ( "github.com/rs/zerolog/log" "github.com/shutter-network/observer/cmd/cli" + "github.com/shutter-network/observer/common" ) func main() { + common.SetupLogging() status := 0 if err := cli.Cmd().Execute(); err != nil { log.Info().Err(err).Msg("failed running server")