add command line option for log file

cc #739
This commit is contained in:
Gokcehan committed 2022-02-06 19:51:52 +03:00
1 parent 5d393da572
commit 47620fa680
11 files changed
+38 -15

No files matched your search

+7 -5
View File
@@ -16,12 +16,14 @@ var (
)
func serve() {
f, err := os.OpenFile(gServerLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
panic(err)
if gLogPath != "" {
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
panic(err)
}
defer f.Close()
log.SetOutput(f)
}
defer f.Close()
log.SetOutput(f)
log.Print("hi!")