Adjust logrus feature of padding all lines less than 44 chars with spaces at the end

This commit is contained in:
Bryan Boreham committed 2015-07-01 12:26:23 +01:00
1 parent d82578d895
commit 67a6961b4b
1 file changed
+8 -3
+8 -3
View File
@@ -21,9 +21,14 @@ func (f *textFormatter) Format(entry *logrus.Entry) ([]byte, error) {
levelText := strings.ToUpper(entry.Level.String())[0:4]
timeStamp := entry.Time.Format("2006/01/02 15:04:05.000000")
fmt.Fprintf(b, "%s: %s %-44s ", levelText, timeStamp, entry.Message)
for k, v := range entry.Data {
fmt.Fprintf(b, " %s=%v", k, v)
if len(entry.Data) > 0 {
fmt.Fprintf(b, "%s: %s %-44s ", levelText, timeStamp, entry.Message)
for k, v := range entry.Data {
fmt.Fprintf(b, " %s=%v", k, v)
}
} else {
// No padding when there's no fields
fmt.Fprintf(b, "%s: %s %s", levelText, timeStamp, entry.Message)
}
b.WriteByte('\n')