Skip to content

Commit

Permalink
create separate function prepareLogDir
Browse files Browse the repository at this point in the history
  • Loading branch information
sgsullivan committed Aug 3, 2022
1 parent e01d337 commit 94a45db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions befehl.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,20 @@ func (instance *Instance) getLogFilePath(host string) string {
return instance.getLogDir() + "/" + host
}

func (instance *Instance) logPayloadRun(host string, output string) error {
func (instance *Instance) prepareLogDir() error {
logDir := instance.getLogDir()
logFilePath := instance.getLogFilePath(host)
if !filesystem.PathExists(logDir) {
if err := os.MkdirAll(logDir, os.FileMode(0700)); err != nil {
return fmt.Errorf("failed creating [%s]: %s", logDir, err)
}
}
return nil
}

func (instance *Instance) logPayloadRun(host string, output string) error {
instance.prepareLogDir()
logFilePath := instance.getLogFilePath(host)

logFile, err := os.Create(logFilePath)
if err != nil {
return fmt.Errorf("error creating [%s]: %s", logFilePath, err)
Expand Down

0 comments on commit 94a45db

Please sign in to comment.