Skip to content

Commit

Permalink
删除兼容代码
Browse files Browse the repository at this point in the history
  • Loading branch information
omigo committed Apr 9, 2016
1 parent 52d6b74 commit b5a4853
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 75 deletions.
Binary file added color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
}
27 changes: 0 additions & 27 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)}
48 changes: 0 additions & 48 deletions log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit b5a4853

Please sign in to comment.