Skip to content

Commit

Permalink
NET-3181 - Allow log file naming like Nomad (#18617)
Browse files Browse the repository at this point in the history
* fixes file name for consul

* added log file

* added tests for rename method
  • Loading branch information
absolutelightning committed Sep 4, 2023
1 parent 84befba commit 7ef0362
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions logging/logfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ func TestLogFile_openNew(t *testing.T) {
require.Contains(t, string(content), msg)
}

func TestLogFile_renameCurrentFile(t *testing.T) {
logFile := LogFile{
fileName: "consul.log",
logPath: testutil.TempDir(t, ""),
duration: defaultRotateDuration,
}
err := logFile.openNew()
require.NoError(t, err)

err = logFile.renameCurrentFile()
require.NoError(t, err)

_, err = os.ReadFile(logFile.FileInfo.Name())
require.Contains(t, err.Error(), "no such file or directory")
}

func TestLogFile_Rotation_MaxBytes(t *testing.T) {
tempDir := testutil.TempDir(t, "LogWriterBytes")
logFile := LogFile{
Expand Down

0 comments on commit 7ef0362

Please sign in to comment.