text_formatter: add field to disable sorting
diff --git a/text_formatter.go b/text_formatter.go
index 2d884c0..71dcb66 100644
--- a/text_formatter.go
+++ b/text_formatter.go
@@ -47,15 +47,22 @@
// Enable logging the full timestamp when a TTY is attached instead of just
// the time passed since beginning of execution.
FullTimestamp bool
+
+ // The fields are sorted by default for a consistent output. For applications
+ // that log extremely frequently and don't use the JSON formatter this may not
+ // be desired.
+ DisableSorting bool
}
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
-
var keys []string = make([]string, 0, len(entry.Data))
for k := range entry.Data {
keys = append(keys, k)
}
- sort.Strings(keys)
+
+ if !f.DisableSorting {
+ sort.Strings(keys)
+ }
b := &bytes.Buffer{}
diff --git a/text_formatter_test.go b/text_formatter_test.go
index 396bc5f..28a9499 100644
--- a/text_formatter_test.go
+++ b/text_formatter_test.go
@@ -32,3 +32,6 @@
checkQuoting(false, errors.New("invalid"))
checkQuoting(true, errors.New("invalid argument"))
}
+
+// TODO add tests for sorting etc., this requires a parser for the text
+// formatter output.