2023-01-15 00:21:08 +08:00
|
|
|
package mylog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLog(t *testing.T) {
|
|
|
|
Debug("time: ", time.Now())
|
|
|
|
Info("time: ", time.Now())
|
|
|
|
Warn("time: ", time.Now())
|
|
|
|
Error("time: ", time.Now())
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
Debugf("time: %s", time.Now())
|
|
|
|
Infof("time: %s", time.Now())
|
|
|
|
Warnf("time: %s", time.Now())
|
|
|
|
Errorf("time: %s", time.Now())
|
|
|
|
}
|
2023-03-14 13:53:07 +08:00
|
|
|
|
|
|
|
func TestLogFile(t *testing.T) {
|
|
|
|
config := DefaultConfig
|
2023-03-20 11:56:29 +08:00
|
|
|
config.NeedLogFile = true
|
2023-03-14 13:53:07 +08:00
|
|
|
Init("debug", config)
|
|
|
|
|
|
|
|
Debug("time: ", time.Now())
|
|
|
|
Info("time: ", time.Now())
|
|
|
|
Warn("time: ", time.Now())
|
|
|
|
Error("time: ", time.Now())
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
Debugf("time: %s", time.Now())
|
|
|
|
Infof("time: %s", time.Now())
|
|
|
|
Warnf("time: %s", time.Now())
|
|
|
|
Errorf("time: %s", time.Now())
|
|
|
|
}
|