File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -5,30 +5,35 @@ crab log 是一个轻量级log库,支持不同级别不同颜色输出,按
55[ ![ Example Output] ( ../doc/log_test.png )] ( log_test.go )
66
77``` go
8- package log
8+ package main
99
1010import (
11- " testing"
1211 " time"
12+
13+ " github.com/dearcode/crab/log"
1314)
1415
15- func TestLog ( t * testing . T ) {
16- Debug (" default log begin" )
17- Infof (" %v test log" , time.Now ())
16+ func main ( ) {
17+ log. Debug (" default log begin" )
18+ log. Infof (" %v test log" , time.Now ())
1819
19- l := NewLogger ()
20+ l := log. NewLogger ()
2021 l.Debug (" logger 1111111111" )
2122 l.Info (" logger 2222222222" )
2223 l.Warningf (" logger 33333 %v " , time.Now ())
2324 l.Errorf (" logger color %v xxxxxx" , time.Now ().UnixNano ())
25+
26+ // 关闭颜色显示
2427 l.SetColor (false )
28+
2529 l.Errorf (" logger no color %v yyyyyy" , time.Now ().UnixNano ())
26- Infof (" %v default has color test log" , time.Now ())
30+ log. Infof (" %v default has color test log" , time.Now ())
2731
28- l.SetOutputFile (" ./vvv.log" ).SetRolling (true )
32+ // 指定输出文件
33+ l.SetOutputFile (" ./vvv.log" ).SetRolling (true )
2934 l.Info (time.Now ())
30- }
3135
36+ }
3237```
3338
3439## Installing
You can’t perform that action at this time.
0 commit comments