Skip to content

Commit

Permalink
udpate logger_test
Browse files Browse the repository at this point in the history
  • Loading branch information
yzj authored and yzj committed Jul 5, 2022
1 parent 831a171 commit 9ee671e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,28 +402,28 @@ WAIT:
}

func TestLogRollerTimeAndCompress(t *testing.T) {
logName := "/tmp/mosn_bench/default.log"
logName := "/tmp/mosn_bench/defaultCompress.log"
rollerName := logName + "." + time.Now().Format("2006-01-02_15")
os.Remove(logName)
os.Remove(rollerName)
// replace rotate interval for test
doRotate = testRotate
doRotate = testRotateByKeep
defer func() {
doRotate = doRotateFunc
doRotate = testRotateByKeep
}()
logger, err := GetOrCreateLogger(logName, &Roller{MaxTime: 10, Handler: rollerHandler, Compress: true})
logger, err := GetOrCreateLogger(logName, &Roller{MaxTime: 2, Handler: rollerHandler, Compress: true})
if err != nil {
t.Fatal(err)
}
// 1111 will be rotated to rollerName
logger.Print(newLogBufferString("1111111"), false)
time.Sleep(11 * time.Second)
time.Sleep(2 * time.Second)
// 2222 will be writed in logName
logger.Print(newLogBufferString("2222222"), false)
time.Sleep(1 * time.Second)
logger.Close() // stop the rotate

if exists(rollerName + compressSuffix) {
if !exists(rollerName + compressSuffix) {
t.Fatalf("compress is failed")
}
}
Expand All @@ -432,7 +432,7 @@ func testRotateByKeep(l *Logger, interval time.Duration) {
doRotateFunc(l, 1*time.Second)
}
func TestLogRollerTimeAndKeep(t *testing.T) {
logName := "/tmp/mosn_bench/default.log"
logName := "/tmp/mosn_bench/defaultKeep.log"
rollerName := logName + "." + time.Now().Format("2006-01-02_15")
os.Remove(logName)
os.Remove(rollerName)
Expand Down

0 comments on commit 9ee671e

Please sign in to comment.