Merge pull request #1047 from lwsanty/fix-race-conditions-on-entry

fix race conditions on entry
This commit is contained in:
Mark Phelps
2020-02-26 18:44:58 -05:00
committed by GitHub
2 changed files with 6 additions and 4 deletions
+2
View File
@@ -122,6 +122,8 @@ func (entry *Entry) WithField(key string, value interface{}) *Entry {
// Add a map of fields to the Entry.
func (entry *Entry) WithFields(fields Fields) *Entry {
entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock()
data := make(Fields, len(entry.Data)+len(fields))
for k, v := range entry.Data {
data[k] = v