Separate file for client

This commit is contained in:
Berger Eugene 2023-02-27 00:54:36 +02:00
parent 757937fbda
commit 6bc7fb3fec
2 changed files with 18 additions and 3 deletions

View File

@ -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 != "" {
@ -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
}

View File

@ -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)
}