Skip to content

Commit

Permalink
Log to STDOUT if running as HTTP service
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jun 18, 2018
1 parent c700839 commit ffbb182
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions interfacer/src/browsh/browsh.go
Expand Up @@ -60,15 +60,19 @@ func Log(msg string) {
if !*isDebug {
return
}
f, oErr := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if oErr != nil {
Shutdown(oErr)
}
defer f.Close()
if *IsHTTPServer {
fmt.Println(msg)
} else {
f, oErr := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if oErr != nil {
Shutdown(oErr)
}
defer f.Close()

msg = msg + "\n"
if _, wErr := f.WriteString(msg); wErr != nil {
Shutdown(wErr)
msg = msg + "\n"
if _, wErr := f.WriteString(msg); wErr != nil {
Shutdown(wErr)
}
}
}

Expand Down

0 comments on commit ffbb182

Please sign in to comment.