From fcf4b8f2294f4097a4cc70639c0f5eb067e1b49c Mon Sep 17 00:00:00 2001 From: Ryan Canty Date: Fri, 18 Nov 2016 11:02:11 -0800 Subject: [PATCH] Added comment documentation for FieldMap --- json_formatter.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/json_formatter.go b/json_formatter.go index 1e3e2bc..f3729bf 100644 --- a/json_formatter.go +++ b/json_formatter.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" ) + type fieldKey string type FieldMap map[fieldKey]string @@ -24,7 +25,17 @@ func (f FieldMap) resolve(key fieldKey) string { type JSONFormatter struct { // TimestampFormat sets the format used for marshaling timestamps. TimestampFormat string - FieldMap FieldMap + + // FieldMap allows users to customize the names of keys for various fields. + // As an example: + // formatter := &JSONFormatter{ + // FieldMap: FieldMap{ + // FieldKeyTime: "@timestamp", + // FieldKeyLevel: "@level", + // FieldKeyLevel: "@message", + // }, + // } + FieldMap FieldMap } func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {