diff --git a/color.png b/color.png new file mode 100644 index 0000000..e6c0ebd Binary files /dev/null and b/color.png differ diff --git a/format_test.go b/format_test.go index 606663f..9ae2b96 100644 --- a/format_test.go +++ b/format_test.go @@ -72,5 +72,7 @@ func TestExtactDateTime(t *testing.T) { // 有两个 2006 ,会出错 format = `{"date": "2006-01-02", "time": "15:04:05.999999999", "Tag": "2006" "level": "info", "file": "log/main.go", "line":88, "log": "message"}` dateFmt, timeFmt = ExtactDateTime(format) + + _, _ = dateFmt, timeFmt }() } diff --git a/log.go b/log.go index e608bde..5e75ba7 100644 --- a/log.go +++ b/log.go @@ -80,30 +80,3 @@ func Tpanicf(tag string, format string, m ...interface{}) { std.Tprintf(v, Panic func Tfatalf(tag string, format string, m ...interface{}) { std.Tprintf(v, FatalLevel, tag, format, m...)} func Tprintf(tag string, format string, m ...interface{}) { std.Tprintf(v, PrintLevel, tag, format, m...)} func Tstackf(tag string, format string, m ...interface{}) { std.Tprintf(v, StackLevel, tag, format, m...)} - -// ======== 兼容 qiniu/log =============== -func SetOutputLevel(l Level) { v = l } - -// ======== 兼容 wothing/log =============== - -// 打印日志时带上 tag -func TraceT(tag string, m ...interface{}) { std.Tprintf(v, TraceLevel, tag, "", m...) } -func DebugT(tag string, m ...interface{}) { std.Tprintf(v, DebugLevel, tag, "", m...) } -func InfoT(tag string, m ...interface{}) { std.Tprintf(v, InfoLevel, tag, "", m...) } -func WarnT(tag string, m ...interface{}) { std.Tprintf(v, WarnLevel, tag, "", m...) } -func ErrorT(tag string, m ...interface{}) { std.Tprintf(v, ErrorLevel, tag, "", m...) } -func PanicT(tag string, m ...interface{}) { std.Tprintf(v, PanicLevel, tag, "", m...) } -func FatalT(tag string, m ...interface{}) { std.Tprintf(v, FatalLevel, tag, "", m...) } -func PrintT(tag string, m ...interface{}) { std.Tprintf(v, PrintLevel, tag, "", m...) } -func StackT(tag string, m ...interface{}) { std.Tprintf(v, StackLevel, tag, "", m...) } - -// 按一定格式打印日志,并在打印日志时带上 tag -func TracefT(tag string, format string, m ...interface{}) { std.Tprintf(v, TraceLevel, tag, format, m...)} -func DebugfT(tag string, format string, m ...interface{}) { std.Tprintf(v, DebugLevel, tag, format, m...)} -func InfofT(tag string, format string, m ...interface{}) { std.Tprintf(v, InfoLevel, tag, format, m...) } -func WarnfT(tag string, format string, m ...interface{}) { std.Tprintf(v, WarnLevel, tag, format, m...) } -func ErrorfT(tag string, format string, m ...interface{}) { std.Tprintf(v, ErrorLevel, tag, format, m...)} -func PanicfT(tag string, format string, m ...interface{}) { std.Tprintf(v, PanicLevel, tag, format, m...)} -func FatalfT(tag string, format string, m ...interface{}) { std.Tprintf(v, FatalLevel, tag, format, m...)} -func PrintfT(tag string, format string, m ...interface{}) {std.Tprintf(v, PrintLevel, tag, format, m...)} -func StackfT(tag string, format string, m ...interface{}) {std.Tprintf(v, StackLevel, tag, format, m...)} diff --git a/log_test.go b/log_test.go index 5c32742..28c93b2 100644 --- a/log_test.go +++ b/log_test.go @@ -144,51 +144,3 @@ func TestFormatLogWithTag(t *testing.T) { Tprintf(uuid, "%d %s", PrintLevel, PrintLevel) Tstackf(uuid, "%d %s", StackLevel, StackLevel) } - -func TestWothingNormalLogWithTag(t *testing.T) { - format := "2006-01-02 15:04:05 tag info examples/main.go:88 message" - SetFormat(format) - SetLevel(AllLevel) - - TraceT(uuid, AllLevel) - TraceT(uuid, TraceLevel) - DebugT(uuid, DebugLevel) - InfoT(uuid, InfoLevel) - WarnT(uuid, WarnLevel) - ErrorT(uuid, ErrorLevel) - func() { - defer func() { - if err := recover(); err == nil { - t.Fail() - } - }() - PanicT(uuid, PanicLevel) - }() - // FatalT(uuid, FatalLevel) - PrintT(uuid, PrintLevel) - StackT(uuid, StackLevel) -} - -func TestWothingFormatLogWithTag(t *testing.T) { - format := "2006-01-02 15:04:05 tag info examples/main.go:88 message" - SetFormat(format) - SetLevel(AllLevel) - - TracefT(uuid, "%d %s", AllLevel, AllLevel) - TracefT(uuid, "%d %s", TraceLevel, TraceLevel) - DebugfT(uuid, "%d %s", DebugLevel, DebugLevel) - InfofT(uuid, "%d %s", InfoLevel, InfoLevel) - WarnfT(uuid, "%d %s", WarnLevel, WarnLevel) - ErrorfT(uuid, "%d %s", ErrorLevel, ErrorLevel) - func() { - defer func() { - if err := recover(); err == nil { - t.Fail() - } - }() - PanicfT(uuid, "%d %s", PanicLevel, PanicLevel) - }() - // FatalfT(uuid,"%d %s", FatalLevel, FatalLevel) - PrintfT(uuid, "%d %s", PrintLevel, PrintLevel) - StackfT(uuid, "%d %s", StackLevel, StackLevel) -}