41 lines
740 B
Go
41 lines
740 B
Go
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())
|
|
}
|
|
|
|
func TestLogFile(t *testing.T) {
|
|
config := DefaultConfig
|
|
config.NeedLogFile = false
|
|
config.LogFilePath = "logs"
|
|
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())
|
|
}
|