Allow disabling timestamp in non-tty output.
This is useful if the output is already being piped to a logger
daemon that will prefix the timestamp by itself (eg: on heroku).
diff --git a/text_formatter.go b/text_formatter.go
index fc0a408..6df95ea 100644
--- a/text_formatter.go
+++ b/text_formatter.go
@@ -32,8 +32,9 @@
type TextFormatter struct {
// Set to true to bypass checking for a TTY before outputting colors.
- ForceColors bool
- DisableColors bool
+ ForceColors bool
+ DisableColors bool
+ DisableTimestamp bool
}
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
@@ -53,7 +54,9 @@
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 {