Skip to content

Commit

Permalink
If the logfile does not exist, create it, or append.
Browse files Browse the repository at this point in the history
  • Loading branch information
davemachado committed Aug 14, 2018
1 parent 0be85a7 commit cbb2608
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ func main() {
if filename == "" {
filename = "/tmp/public-api.log"
}
f, _ := os.Create(filename)
// If the file does not exist, create it. Otherwise, append to the file.
f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
logger := NewLogger(Options{
Out: io.MultiWriter(f, os.Stdout),
})
Expand Down

0 comments on commit cbb2608

Please sign in to comment.