From 8a6d61c26075c8fcdbecce64803e521566ebe7d9 Mon Sep 17 00:00:00 2001 From: jamesread Date: Wed, 29 Oct 2025 22:05:00 +0000 Subject: [PATCH] feat: enable JSON logging support with OLIVETIN_LOG_FORMAT=json environment variable --- service/main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/service/main.go b/service/main.go index 74e89ba..1068d81 100644 --- a/service/main.go +++ b/service/main.go @@ -51,10 +51,16 @@ func init() { } func initLog() { - log.SetFormatter(&log.TextFormatter{ - ForceQuote: true, - DisableTimestamp: true, - }) + logFormat := os.Getenv("OLIVETIN_LOG_FORMAT") + + if logFormat == "json" { + log.SetFormatter(&log.JSONFormatter{}) + } else { + log.SetFormatter(&log.TextFormatter{ + ForceQuote: true, + DisableTimestamp: true, + }) + } // Use debug this early on to catch details about startup errors. The // default config will raise the log level later, if not set.