refactor: simplify the code (#2763)

* refactor: simplify the code

* fix: fix data race

* refactor: simplify the code

* refactor: simplify the code
This commit is contained in:
chen quan
2023-01-07 13:32:56 +08:00
committed by GitHub
parent 559726112c
commit dc260f196a
3 changed files with 24 additions and 75 deletions

View File

@@ -269,7 +269,10 @@ func combineGlobalFields(fields []LogField) []LogField {
return fields
}
return append(globals.([]LogField), fields...)
originLogFields := globals.([]LogField)
logFields := append(make([]LogField, 0, len(originLogFields)+len(fields)), originLogFields...)
return append(logFields, fields...)
}
func output(writer io.Writer, level string, val interface{}, fields ...LogField) {