github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/swarm/log/log.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 19:16:43</date> 10 //</624450113250529280> 11 12 package log 13 14 import ( 15 l "github.com/ethereum/go-ethereum/log" 16 "github.com/ethereum/go-ethereum/metrics" 17 ) 18 19 const ( 20 //CallDepth设置为1,以影响 21 //调用l.output()时跳过堆栈帧为1的日志消息 22 CallDepth = 1 23 ) 24 25 //warn是日志的方便别名。warn with stats 26 func Warn(msg string, ctx ...interface{}) { 27 metrics.GetOrRegisterCounter("warn", nil).Inc(1) 28 l.Output(msg, l.LvlWarn, CallDepth, ctx...) 29 } 30 31 //错误是日志的方便别名。使用stats时出错 32 func Error(msg string, ctx ...interface{}) { 33 metrics.GetOrRegisterCounter("error", nil).Inc(1) 34 l.Output(msg, l.LvlError, CallDepth, ctx...) 35 } 36 37 //crit是log.crit和stats的方便别名 38 func Crit(msg string, ctx ...interface{}) { 39 metrics.GetOrRegisterCounter("crit", nil).Inc(1) 40 l.Output(msg, l.LvlCrit, CallDepth, ctx...) 41 } 42 43 //信息是日志的一个方便别名。带有统计信息的信息 44 func Info(msg string, ctx ...interface{}) { 45 metrics.GetOrRegisterCounter("info", nil).Inc(1) 46 l.Output(msg, l.LvlInfo, CallDepth, ctx...) 47 } 48 49 //调试是日志的一个方便别名。使用stats进行调试 50 func Debug(msg string, ctx ...interface{}) { 51 metrics.GetOrRegisterCounter("debug", nil).Inc(1) 52 l.Output(msg, l.LvlDebug, CallDepth, ctx...) 53 } 54 55 //trace是日志的方便别名。trace with stats 56 func Trace(msg string, ctx ...interface{}) { 57 metrics.GetOrRegisterCounter("trace", nil).Inc(1) 58 l.Output(msg, l.LvlTrace, CallDepth, ctx...) 59 } 60