feat: enable JSON logging support with OLIVETIN_LOG_FORMAT=json environment variable

This commit is contained in:
jamesread 2025-10-29 22:05:00 +00:00
parent f337e05eaf
commit 8a6d61c260
1 changed files with 10 additions and 4 deletions

View File

@ -51,10 +51,16 @@ func init() {
} }
func initLog() { func initLog() {
log.SetFormatter(&log.TextFormatter{ logFormat := os.Getenv("OLIVETIN_LOG_FORMAT")
ForceQuote: true,
DisableTimestamp: true, 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 // Use debug this early on to catch details about startup errors. The
// default config will raise the log level later, if not set. // default config will raise the log level later, if not set.