From bbefe801d3682fc0b0f0fd5617e80ca96b65613e Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 9 Feb 2022 16:11:35 -0500 Subject: [PATCH] pretty up logging --- log.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/log.go b/log.go index bd15c9a..ff4e971 100644 --- a/log.go +++ b/log.go @@ -25,7 +25,7 @@ import ( // log.Default() not added until go 1.16 func logdefault() *log.Logger { - return log.New(os.Stderr, os.Args[0], log.LstdFlags) + return log.New(os.Stderr, "", log.LstdFlags) } var elog = logdefault() @@ -50,28 +50,28 @@ func initLogging(elogname, ilogname, dlogname string) { func openlog(name string, prio syslog.Priority) *log.Logger { if name == "stderr" { - return log.New(os.Stderr, os.Args[0], log.LstdFlags) + return log.New(os.Stderr, "", log.LstdFlags) } if name == "stdout" { - return log.New(os.Stdout, os.Args[0], log.LstdFlags) + return log.New(os.Stdout, "", log.LstdFlags) } if name == "null" { - return log.New(ioutil.Discard, os.Args[0], log.LstdFlags) + return log.New(ioutil.Discard, "", log.LstdFlags) } if name == "syslog" { - logger, err := syslog.NewLogger(syslog.LOG_UUCP|prio, 0) + w, err := syslog.New(syslog.LOG_UUCP|prio, "honk") if err != nil { elog.Printf("can't create syslog: %s", err) return logdefault() } - return logger + return log.New(w, "", 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) return logdefault() } - logger := log.New(fd, os.Args[0], log.LstdFlags) + logger := log.New(fd, "", log.LstdFlags) logger.Printf("new log started") return logger }