Merge pull request #10 from pushrax/add-forced-colors

Add option to force TextFormatter to use colors
This commit is contained in:
Simon Eskildsen
2014-03-16 16:17:15 -07:00
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -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