Skip to content

Instantly share code, notes, and snippets.

@pjvds
Created March 9, 2015 18:59
Show Gist options
  • Save pjvds/2b5e16f9834883bf24b2 to your computer and use it in GitHub Desktop.
Save pjvds/2b5e16f9834883bf24b2 to your computer and use it in GitHub Desktop.
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