From 7a3bf5bffb13a9cc35953ebd9074d00cdc3fae10 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 6 Feb 2022 00:45:54 -0500 Subject: [PATCH] allow stdout logging --- log.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/log.go b/log.go index d100109..13675f5 100644 --- a/log.go +++ b/log.go @@ -47,6 +47,12 @@ func openlog(name string, prio syslog.Priority) *log.Logger { if name == "stderr" { return log.Default() } + if name == "stdout" { + return log.New(os.Stdout, os.Args[0], log.LstdFlags) + } + if name == "null" { + return log.New(ioutil.Discard, os.Args[0], log.LstdFlags) + } if name == "syslog" { logger, err := syslog.NewLogger(syslog.LOG_UUCP|prio, 0) if err != nil { @@ -55,9 +61,6 @@ func openlog(name string, prio syslog.Priority) *log.Logger { } return logger } - if name == "null" { - return log.New(ioutil.Discard, os.Args[0], log.LstdFlags) - } fd, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600) if err != nil { elog.Printf("can't open log file %s: %s", name, err)