Skip to content

Commit

Permalink
TraceContext AddFields
Browse files Browse the repository at this point in the history
  • Loading branch information
Дмитрий Седых committed Sep 20, 2016
1 parent d8f8788 commit 9f14ed0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ func (t *TraceContext) Stop(err *error) {
}
}

func (t *TraceContext) AddField(name string, value interface{}) *TraceContext {
if t.context.fields == nil {
t.context.fields = make(Fields, 1)
}
t.context.fields[name] = value
return t
}

func (t *TraceContext) AddFields(fields Fields) *TraceContext {
if t.context.fields == nil {
t.context.fields = fields
} else {
for name, value := range fields {
t.context.fields[name] = value
}
}
return t
}

// Trace returns a new entry with a Stop method to fire off a corresponding
// completion log, useful with defer.
func (c *Context) Trace(message string) *TraceContext {
Expand Down

0 comments on commit 9f14ed0

Please sign in to comment.