forked from phuslu/log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdlog_test.go
45 lines (38 loc) · 1.11 KB
/
stdlog_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package log
import (
"fmt"
stdLog "log"
"os"
"testing"
)
func TestStdWriter(t *testing.T) {
w := &stdLogWriter{
logger: Logger{
Level: InfoLevel,
Writer: IOWriter{os.Stderr},
},
level: DebugLevel,
}
fmt.Fprint(w, "hello from stdLog debug Print")
fmt.Fprintln(w, "hello from stdLog debug Println")
fmt.Fprintf(w, "hello from stdLog debug %s", "Printf")
w.level = InfoLevel
fmt.Fprint(w, "hello from stdLog info Print")
fmt.Fprintln(w, "hello from stdLog info Println")
fmt.Fprintf(w, "hello from stdLog info %s", "Printf")
}
func TestStdLogger(t *testing.T) {
logger := Logger{
Level: DebugLevel,
Caller: 1,
Writer: &ConsoleWriter{ColorOutput: true, EndWithMessage: true},
}
stdLog := logger.Std(InfoLevel, NewContext(nil).Str("tag", "std_log").Value(), "", stdLog.LstdFlags)
stdLog.Print("hello from stdLog Print")
stdLog.Println("hello from stdLog Println")
stdLog.Printf("hello from stdLog %s", "Printf")
stdLog = logger.Std(InfoLevel, nil, "", 0)
stdLog.Print("hello from stdLog Print")
stdLog.Println("hello from stdLog Println")
stdLog.Printf("hello from stdLog %s", "Printf")
}