Compare commits

...

1 Commits

Author SHA1 Message Date
Mark Phelps cc70782477 add mutex on entry, not logging the global mutex 2020-04-16 09:20:41 -04:00
1 changed files with 4 additions and 2 deletions

View File

@ -75,6 +75,8 @@ type Entry struct {
// err may contain a field formatting error
err string
mu sync.Mutex
}
func NewEntry(logger *Logger) *Entry {
@ -122,8 +124,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()
entry.mu.Lock()
defer entry.mu.Unlock()
data := make(Fields, len(entry.Data)+len(fields))
for k, v := range entry.Data {
data[k] = v