Skip to content

Commit

Permalink
Fix logfile location (#240)
Browse files Browse the repository at this point in the history
* Change logfile location to dir with permissions

* Fix test
  • Loading branch information
marcauberer committed Nov 29, 2021
1 parent dac81dc commit ddcc907
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ nfpms:
dst: /etc/bash_completion.d/compose-generator
- dst: /usr/lib/compose-generator/templates
type: dir
- dst: /usr/lib/compose-generator/log
- dst: /var/log/compose-generator
type: dir
release:
name_template: v{{ .Tag }}
Expand Down
2 changes: 1 addition & 1 deletion src/util/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func getLogfilesPath() string {
return "/cg/log"
}
if isLinux() { // Linux
return "/usr/lib/compose-generator/log"
return "/var/log/compose-generator"
}
// Windows
path, err := executable()
Expand Down
2 changes: 1 addition & 1 deletion src/util/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func TestGetLogfilesPath3(t *testing.T) {
// Execute test
result := getLogfilesPath()
// Assert
assert.Equal(t, "/usr/lib/compose-generator/log", result)
assert.Equal(t, "/var/log/compose-generator", result)
}

func TestGetLogfilesPath4(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion src/util/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var (

func init() {
// Open logfile

logfile, err := os.OpenFile(getLogfilePath(), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit ddcc907

Please sign in to comment.