Omit log timestamps when running under systemd

The journal will already have timestamps for each logged message.
This commit is contained in:
Darell Tan
2023-08-04 00:58:23 +08:00
parent ba9a42b64e
commit 420313906f

View File

@@ -66,6 +66,11 @@ func parseConfig(fname string) (cfg *config, err error) {
func main() {
flag.Parse()
// check if we are running under systemd, and if so, dont output timestamps
if a, b := os.Getenv("INVOCATION_ID"), os.Getenv("JOURNAL_STREAM"); a != "" && b != "" {
log.SetFlags(0)
}
cfg, err := parseConfig(*configFile)
if err != nil {
log.Fatalf("config file error: %v", err)