diff --git a/text_formatter.go b/text_formatter.go index e77da11..fcc074f 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -34,6 +34,9 @@ type TextFormatter struct { // Set to true to bypass checking for a TTY before outputting colors. ForceColors bool DisableColors bool + // Set to true to disable timestamp logging (useful when the output + // is redirected to a logging system already adding a timestamp) + DisableTimestamp bool } func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { @@ -53,7 +56,9 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { if isColored { printColored(b, entry, keys) } else { - f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339)) + if !f.DisableTimestamp { + f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339)) + } f.appendKeyValue(b, "level", entry.Level.String()) f.appendKeyValue(b, "msg", entry.Message) for _, key := range keys {