Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Add a LogData->LogRecord converter
Browse files Browse the repository at this point in the history
  • Loading branch information
bhs committed Sep 26, 2016
1 parent 0004729 commit c4d24cd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions span.go
Expand Up @@ -79,6 +79,8 @@ type Span interface {
//
// The keys must all be strings. The values may be strings, numeric types,
// bools, Go error instances, or arbitrary structs.
//
// (Note to implementors: consider the log.InterleavedKVToFields() helper)
LogKV(alternatingKeyValues ...interface{})

// SetBaggageItem sets a key:value pair on this Span and its SpanContext
Expand Down Expand Up @@ -155,3 +157,14 @@ type LogData struct {
Event string
Payload interface{}
}

// ToLogRecord converts a deprecated LogData to a non-deprecated LogRecord
func (ld *LogData) ToLogRecord() LogRecord {
return LogRecord{
Timestamp: ld.Timestamp,
Fields: []log.Field{
log.String("event", ld.Event),
log.Object("payload", ld.Payload),
},
}
}

0 comments on commit c4d24cd

Please sign in to comment.