Adds WithTime to Logger and Entry types, as well as a pure module-level function.

This commit is contained in:
Simon Brisson
2018-06-29 10:53:51 -04:00
parent 52b92f5b89
commit 725f3be199
4 changed files with 84 additions and 1 deletions
+6 -1
View File
@@ -83,7 +83,12 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
for k, v := range fields {
data[k] = v
}
return &Entry{Logger: entry.Logger, Data: data}
return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time}
}
// Overrides the time of the Entry.
func (entry *Entry) WithTime(t time.Time) *Entry {
return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t}
}
// This function is not declared with a pointer value because otherwise