Skip to content

Commit

Permalink
Fix log file path (#2478)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakulkar-msft authored Dec 4, 2023
1 parent 3feeb6e commit 11596f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/lifecyleMgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ func (lcm *lifecycleMgr) Exit(o OutputBuilder, applicationExitCode ExitCode) {
exitCode: applicationExitCode,
}

AzcopyCurrentJobLogger.CloseLog()
if applicationExitCode != EExitCode.NoExit() {
// stall forever until the success message is printed and program exits
lcm.SurrenderControl()
Expand Down
8 changes: 7 additions & 1 deletion common/rotatingWriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ func (w *rotatingWriter) rotate(suffix int32) error {
}

func (w *rotatingWriter) Close() error {
return w.file.Close()
if err := w.file.Close(); err != nil {
return err
}
if err := os.Rename(w.filePath, w.filePath + ".log"); err != nil {
return err
}
return nil
}

func (w *rotatingWriter) Write(p []byte) (n int, err error) {
Expand Down
2 changes: 1 addition & 1 deletion common/rotatingWriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestRotatingWriter(t *testing.T) {
a.Nil(err)
a.Equal(3, len(entries))
f = convertToMap(entries)
a.Contains(f, logFileName)
a.Contains(f, logFileName + ".log")
a.Contains(f, logFileName + ".0.log")
a.Contains(f, logFileName + ".1.log")
}

0 comments on commit 11596f8

Please sign in to comment.