mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-05-23 02:18:07 +08:00
36 lines
665 B
Go
36 lines
665 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|FlagDebug),
|
||
|
)
|
||
|
|
||
|
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 输出")
|
||
|
time.Sleep(100 * time.Millisecond)
|
||
|
}
|
||
|
}
|