remove timestamp from logging if started via systemd

This commit is contained in:
Adora Laura Kalb 2023-07-07 11:04:15 +02:00
parent 220ce63d95
commit 3966020cfe
Signed by: adoralaura
GPG key ID: 7A4552166FC8C056

View file

@ -16,8 +16,12 @@ import (
var FlagDebug bool var FlagDebug bool
func InitializeLogger() { func InitializeLogger() {
if os.Getenv("INVOCATION_ID") == "" {
// detect systemd
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}) 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 { if FlagDebug {
zerolog.SetGlobalLevel(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel)