From 3966020cfe2c3bb3b16d451e5bfb4033c96c9240 Mon Sep 17 00:00:00 2001 From: lauralani Date: Fri, 7 Jul 2023 11:04:15 +0200 Subject: [PATCH] remove timestamp from logging if started via systemd --- log/logger.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/log/logger.go b/log/logger.go index c30c00f..dcde84d 100644 --- a/log/logger.go +++ b/log/logger.go @@ -16,8 +16,12 @@ import ( var FlagDebug bool func InitializeLogger() { - - log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}) + if os.Getenv("INVOCATION_ID") == "" { + // detect systemd + log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}) + } else { + log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, NoColor: true, PartsExclude: []string{"time"}}) + } if FlagDebug { zerolog.SetGlobalLevel(zerolog.DebugLevel)