From 7a1f601cfd7604dd99fa6d6af0aa3e2a3f3de6b4 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Wed, 31 Aug 2016 23:54:59 +1000 Subject: [PATCH] Added ability to disable level text truncation. Fixes #406 --- text_formatter.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/text_formatter.go b/text_formatter.go index cce61f2..a51bf19 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -54,6 +54,9 @@ type TextFormatter struct { // that log extremely frequently and don't use the JSON formatter this may not // be desired. DisableSorting bool + + // Disables the truncation of the level text to 4 characters. + DisableLevelTruncation bool } func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { @@ -113,7 +116,10 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin levelColor = blue } - levelText := strings.ToUpper(entry.Level.String())[0:4] + levelText := strings.ToUpper(entry.Level.String()) + if !f.DisableLevelTruncation { + levelText = levelText[0:4] + } if !f.FullTimestamp { fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message)