mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-02-23 15:32:15 +08:00
37 lines
708 B
Go
37 lines
708 B
Go
package simplelog
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestLog(t *testing.T) {
|
|
log := NewLog()
|
|
|
|
log2 := NewLog(
|
|
WithWriter(os.Stdout),
|
|
WithTimeFormat("2006-01-02"),
|
|
WithLogFormat("%-10s %s %v %s =-=-> %s\n"),
|
|
WithLogFlag(FlagInfo|FlagWarn|FlagError),
|
|
)
|
|
|
|
fmt.Printf("simpleLog => %#v\n", log)
|
|
|
|
fmt.Println("=========================================================")
|
|
|
|
for i := 0; i < 5; i++ {
|
|
log.Debug("测试 Debug 输出")
|
|
time.Sleep(100 * time.Millisecond)
|
|
}
|
|
|
|
fmt.Println("=========================================================")
|
|
|
|
for i := 0; i < 5; i++ {
|
|
log2.Debug("测试 Debug 输出")
|
|
log2.Info("测试 Info 输出")
|
|
time.Sleep(100 * time.Millisecond)
|
|
}
|
|
}
|