Created
March 9, 2015 18:59
-
-
Save pjvds/2b5e16f9834883bf24b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Format(entry tidy.Entry) ([]byte, error) { | |
buffer := make([]byte, 0) | |
term := terminal.TerminalWriter{buffer} | |
color := colors[entry.Level] | |
term.Color(color).Print(entry.Timestamp.Format("15:04:05")) | |
term.Print(entry.Level.FixedString()) | |
term.Print(" [").Print(entry.Module).Print("] ").Reset() | |
term.Print(" ").Print(entry.Message) | |
if len(entry.Fields) > 0 { | |
term.Print("\t") | |
for key, value := range entry.Fields { | |
term.Color(color).Print(" ").Print(key).Print("=").Reset() | |
term.Print(value) | |
} | |
} | |
term.Print("\n") | |
_, err := buffer.WriteTo(writer) | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment