2019-11-06 02:11:12 +00:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-11-07 09:04:36 +00:00
|
|
|
"time"
|
2019-11-06 02:11:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestLog(t *testing.T) {
|
|
|
|
Debugf("this is %s message", "debug")
|
|
|
|
Infof("this is %s message", "info")
|
|
|
|
Errorf("this is %s message", "error")
|
|
|
|
// Panicf("this is %s message", "panic")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLogWithConfig(t *testing.T) {
|
|
|
|
lc := NewLogConfig()
|
|
|
|
_ = lc.Level.Set("info")
|
2019-11-07 09:04:36 +00:00
|
|
|
lc.Name = "main"
|
2019-11-06 02:11:12 +00:00
|
|
|
lc.Init()
|
|
|
|
|
|
|
|
Debugf("this is %s message", "debug")
|
|
|
|
Infof("this is %s message", "info")
|
|
|
|
Errorf("this is %s message", "error")
|
|
|
|
// Panicf("this is %s message", "panic")
|
|
|
|
}
|
2019-11-07 09:04:36 +00:00
|
|
|
|
|
|
|
func TestLogRote(t *testing.T) {
|
|
|
|
lc := NewLogConfig()
|
|
|
|
_ = lc.Level.Set("info")
|
|
|
|
lc.Name = "main"
|
|
|
|
lc.MaxSize = 1
|
|
|
|
|
|
|
|
lc.Init()
|
|
|
|
|
|
|
|
for {
|
|
|
|
Infof("this is %s message", "info")
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
}
|
|
|
|
}
|