Skip to content

Commit

Permalink
fix: setFields create fields if not initielaized
Browse files Browse the repository at this point in the history
  • Loading branch information
Ak-Army committed Aug 29, 2024
1 parent da4848d commit 55ad774
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions xlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ func New(c Config) Logger {
if l.output == nil {
l.output = NewOutputChannel(NewConsoleOutput())
}
for k, v := range c.Fields {
l.SetField(k, v)
}
l.SetFields(c.Fields)
l.disablePooling = c.DisablePooling
l.disableCallerInfo = c.DisableCallerInfo
return l
Expand Down Expand Up @@ -259,6 +257,9 @@ func (l *logger) SetField(name string, value interface{}) {

// SetFields
func (l *logger) SetFields(fields F) {
if l.fields == nil {
l.fields = map[string]interface{}{}
}
for name, value := range fields {
l.fields[name] = value
}
Expand Down

0 comments on commit 55ad774

Please sign in to comment.