From 3e9d38f80da8c10426533fbe6821b3fa1ff82dd8 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Mon, 15 Dec 2014 20:02:02 +0100 Subject: [PATCH 1/2] 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). --- text_formatter.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 @@ func miniTS() int { 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 @@ 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 { From f0a637a8341cf1af53223928eedf5f4804e08510 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Mon, 15 Dec 2014 21:58:26 +0100 Subject: [PATCH 2/2] Document new option --- text_formatter.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index 6df95ea..ac0b01e 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -32,8 +32,10 @@ func miniTS() int { type TextFormatter struct { // Set to true to bypass checking for a TTY before outputting colors. - ForceColors bool - DisableColors bool + 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 }