MCPcopy
hub / github.com/aceld/zinx / TestStdZLog

Function TestStdZLog

zlog/zlog_test.go:9–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestStdZLog(t *testing.T) {
10
11 //测试 默认debug输出
12 zlog.Debug("zinx debug content1")
13 zlog.Debug("zinx debug content2")
14
15 zlog.Debugf(" zinx debug a = %d\n", 10)
16
17 //设置log标记位,加上长文件名称 和 微秒 标记
18 zlog.ResetFlags(zlog.BitDate | zlog.BitLongFile | zlog.BitLevel)
19 zlog.Info("zinx info content")
20
21 //设置日志前缀,主要标记当前日志模块
22 zlog.SetPrefix("MODULE")
23 zlog.Error("zinx error content")
24
25 //添加标记位
26 zlog.AddFlag(zlog.BitShortFile | zlog.BitTime)
27 zlog.Stack(" Zinx Stack! ")
28
29 //设置日志写入文件
30 zlog.SetLogFile("./log", "testfile.log")
31 zlog.Debug("===> zinx debug content ~~666")
32 zlog.Debug("===> zinx debug content ~~888")
33 zlog.Error("===> zinx Error!!!! ~~~555~~~")
34
35 //调试隔离级别
36 zlog.Debug("=================================>")
37 //1.debug
38 zlog.SetLogLevel(zlog.LogInfo)
39 zlog.Debug("===> 调试Debug:debug不应该出现")
40 zlog.Info("===> 调试Debug:info应该出现")
41 zlog.Warn("===> 调试Debug:warn应该出现")
42 zlog.Error("===> 调试Debug:error应该出现")
43 //2.info
44 zlog.SetLogLevel(zlog.LogWarn)
45 zlog.Debug("===> 调试Info:debug不应该出现")
46 zlog.Info("===> 调试Info:info不应该出现")
47 zlog.Warn("===> 调试Info:warn应该出现")
48 zlog.Error("===> 调试Info:error应该出现")
49 //3.warn
50 zlog.SetLogLevel(zlog.LogError)
51 zlog.Debug("===> 调试Warn:debug不应该出现")
52 zlog.Info("===> 调试Warn:info不应该出现")
53 zlog.Warn("===> 调试Warn:warn不应该出现")
54 zlog.Error("===> 调试Warn:error应该出现")
55 //4.error
56 zlog.SetLogLevel(zlog.LogPanic)
57 zlog.Debug("===> 调试Error:debug不应该出现")
58 zlog.Info("===> 调试Error:info不应该出现")
59 zlog.Warn("===> 调试Error:warn不应该出现")
60 zlog.Error("===> 调试Error:error不应该出现")
61}
62
63func TestZLogger(t *testing.T) {
64}

Callers

nothing calls this directly

Calls 11

DebugFunction · 0.92
DebugfFunction · 0.92
ResetFlagsFunction · 0.92
InfoFunction · 0.92
SetPrefixFunction · 0.92
ErrorFunction · 0.92
AddFlagFunction · 0.92
StackFunction · 0.92
SetLogFileFunction · 0.92
SetLogLevelFunction · 0.92
WarnFunction · 0.92

Tested by

no test coverage detected