Skip to content

Commit

Permalink
feat(text): increase time formatting performance
Browse files Browse the repository at this point in the history
related: #1
  • Loading branch information
pjvds committed Jun 4, 2015
1 parent e65ca41 commit 8f2ca5a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions text.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var colors = [][]byte{
var reset = []byte("\033[0m")
var newline = []byte("\n")
var whitespace = []byte(" ")
var colon = []byte(":")

type ColoredTextFormatter struct{}

Expand All @@ -25,9 +26,14 @@ func (this ColoredTextFormatter) FormatTo(writer io.Writer, entry Entry) error {
defer buffer.Free()

color := colors[entry.Level]

buffer.Write(color)
buffer.WriteString(entry.Timestamp.Format("15:04:05 "))

buffer.WriteTwoDigits(entry.Timestamp.Hour())
buffer.Write(colon)
buffer.WriteTwoDigits(entry.Timestamp.Minute())
buffer.Write(colon)
buffer.WriteTwoDigits(entry.Timestamp.Second())

buffer.WriteString(chars[entry.Level])
buffer.WriteString(" ⟨")
buffer.WriteString(entry.Module.String())
Expand Down

0 comments on commit 8f2ca5a

Please sign in to comment.