Skip to content

Commit

Permalink
Separate file for client
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Feb 26, 2023
1 parent 757937f commit 6bc7fb3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const (
LogFileMode = os.FileMode(0600)
)

var LogFilePath = filepath.Join(os.TempDir(), fmt.Sprintf("process-compose-%s.log", mustUser()))
func GetLogFilePath() string {
return filepath.Join(os.TempDir(), fmt.Sprintf("process-compose-%s%s.log", mustUser(), mode()))
}

func procCompHome() string {
if env := os.Getenv(pcConfigEnv); env != "" {
Expand Down Expand Up @@ -58,3 +60,17 @@ func mustUser() string {
}
return usr.Username
}

func mode() string {
if isClient() {
return "-client"
}
return ""
}

func isClient() bool {
if len(os.Args) > 1 {
return os.Args[1] == "process"
}
return false
}
3 changes: 1 addition & 2 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ func setupLogger(output io.Writer) {
}

func main() {

file, err := os.OpenFile(config.LogFilePath, config.LogFileFlags, config.LogFileMode)
file, err := os.OpenFile(config.GetLogFilePath(), config.LogFileFlags, config.LogFileMode)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 6bc7fb3

Please sign in to comment.