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
+8
View File
@@ -5,6 +5,7 @@ import (
"os"
"sync"
"sync/atomic"
"time"
)
type Logger struct {
@@ -112,6 +113,13 @@ func (logger *Logger) WithError(err error) *Entry {
return entry.WithError(err)
}
// Overrides the time of the log entry.
func (logger *Logger) WithTime(t time.Time) *Entry {
entry := logger.newEntry()
defer logger.releaseEntry(entry)
return entry.WithTime(t)
}
func (logger *Logger) Debugf(format string, args ...interface{}) {
if logger.level() >= DebugLevel {
entry := logger.newEntry()