allow stdout logging

This commit is contained in:
Ted Unangst 2022-02-06 00:45:54 -05:00
parent 7eef6ae5d0
commit 7a3bf5bffb
1 changed files with 6 additions and 3 deletions

9
log.go
View File

@ -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)