File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 44 "fmt"
55 "io"
66 "sync"
7+ "time"
78
89 "github.com/sirupsen/logrus"
910)
@@ -13,7 +14,6 @@ import (
1314// formatter to format the entry to a Logstash format before sending.
1415//
1516// To initialize it use the `New` function.
16- //
1717type Hook struct {
1818 writer io.Writer
1919 formatter logrus.Formatter
@@ -117,8 +117,11 @@ func DefaultFormatter(fields logrus.Fields) logrus.Formatter {
117117 }
118118
119119 return LogstashFormatter {
120- Formatter : & logrus.JSONFormatter {FieldMap : logstashFieldMap },
121- Fields : fields ,
120+ Formatter : & logrus.JSONFormatter {
121+ FieldMap : logstashFieldMap ,
122+ TimestampFormat : time .RFC3339Nano ,
123+ },
124+ Fields : fields ,
122125 }
123126}
124127
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ func TestDefaultFormatterWithEmptyFields(t *testing.T) {
125125 "\" Key1\" :\" Value1\" " ,
126126 "\" @version\" :\" 1\" " ,
127127 "\" type\" :\" log\" " ,
128- fmt .Sprintf ("\" @timestamp\" :\" %s\" " , now .Format (time .RFC3339 )),
128+ fmt .Sprintf ("\" @timestamp\" :\" %s\" " , now .Format (time .RFC3339Nano )),
129129 }
130130
131131 for _ , exp := range expected {
You can’t perform that action at this time.
0 commit comments