Skip to content

Commit

Permalink
repair issues "#1"
Browse files Browse the repository at this point in the history
  • Loading branch information
auula committed Apr 19, 2020
1 parent e0d33a9 commit e8d1c44
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ func (f *fileLog) outPutErr(model level, v string) {
func buildFormat(str string) string {
match := []string{"{level}", "{time}", "{position}", "{message}"}
for i, mc := range match {
if strings.Contains(string(str), mc) && match[i] == mc {
//用来检测顺序的
if !(match[i] == mc) {
panic("你的匹配符顺序不对!!!正确的顺序是: {level} > {time} > {position} > {message}!!!")
}
if strings.Contains(string(str), mc) {
if mc == match[0] {
str = strings.Replace(string(str), mc, "[%s]", -1)
}
str = strings.Replace(string(str), mc, "%s", -1)
} else {
panic("YourLogMessageFormatIsMissing:" + mc + "Tag!!")
}

}
return str
}

0 comments on commit e8d1c44

Please sign in to comment.