From 436d68dedaecf5f486395a776d1ceb942606177d Mon Sep 17 00:00:00 2001 From: Justin Li Date: Sat, 15 Mar 2014 23:36:51 -0400 Subject: [PATCH] Add option to force TextFormatter to use colors --- text_formatter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/text_formatter.go b/text_formatter.go index 5c50c91..4df816b 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -18,12 +18,14 @@ const ( ) type TextFormatter struct { + // Set to true to bypass checking for a TTY before outputting colors. + ForceColors bool } func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { var serialized []byte - if ttyutils.IsTerminal(os.Stdout.Fd()) { + if f.ForceColors || ttyutils.IsTerminal(os.Stdout.Fd()) { levelText := strings.ToUpper(entry.Data["level"].(string))[0:4] levelColor := blue