Skip to content

Commit

Permalink
fix(main): fixes log file creation if run as root
Browse files Browse the repository at this point in the history
desc: Fixes log file creation if Popeye was run with root user on linux.
      The file creation was failing with permission denied error.
      It was mentioned here: derailed#301

[email protected]
  • Loading branch information
Tamás Mojzes committed Sep 13, 2024
1 parent e466645 commit 37e70cb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

func init() {
mod := os.O_CREATE | os.O_APPEND | os.O_WRONLY
if file, err := os.OpenFile(pkg.LogFile, mod, 0644); err == nil {
mod := os.O_APPEND | os.O_WRONLY
if file, err := os.OpenFile(pkg.LogFile, mod, 0o644); err == nil {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: file})
} else {
fmt.Printf("Unable to create Popeye log file %v. Exiting...", err)
fmt.Printf("Unable to create Popeye log file %v. Exiting...\n", err)
os.Exit(1)
}
}
Expand Down

0 comments on commit 37e70cb

Please sign in to comment.