fix logging for backend
Ted Unangst tedu@tedunangst.com
Wed, 09 Feb 2022 16:30:58 -0500
3 files changed,
12 insertions(+),
1 deletions(-)
M
backend.go
→
backend.go
@@ -104,7 +104,7 @@ srv.Accept(lis)
} func runBackendServer() { - proc := exec.Command(os.Args[0], "-datadir", dataDir, "backend") + proc := exec.Command(os.Args[0], reexecArgs("backend")...) proc.Stdout = os.Stdout proc.Stderr = os.Stderr err := proc.Start()
M
honk.go
→
honk.go
@@ -259,6 +259,13 @@ db.Exec("delete from honkers where xid like ? and flavor = 'dub'", xid)
db.Exec("delete from doovers where rcpt like ?", xid) } +func reexecArgs(cmd string) []string { + args := []string{"-datadir", dataDir} + args = append(args, loggingArgs()...) + args = append(args, cmd) + return args +} + func main() { flag.StringVar(&dataDir, "datadir", dataDir, "data directory") flag.StringVar(&viewDir, "viewdir", viewDir, "view directory")
M
log.go
→
log.go
@@ -42,6 +42,10 @@ flag.StringVar(&alllogname, "log", "stderr", "combined log file (or stderr, null, syslog)")
} +func loggingArgs() []string { + return []string{"-errorlog", elogname, "-infolog", ilogname, "-debuglog", dlogname} +} + func initLogging(elogname, ilogname, dlogname string) { elog = openlog(elogname, syslog.LOG_ERR) ilog = openlog(ilogname, syslog.LOG_INFO)