File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ func (l *Config) Init() error {
5959 case "json" :
6060 formatter = & logrus.JSONFormatter {}
6161 case "default" :
62- formatter = & DefaultLogFormatter {}
62+ formatter = & DefaultLogFormatter {
63+ TimestampFormat : time .RFC3339Nano ,
64+ }
6365 default :
6466 return fmt .Errorf ("Unknown log format '%s'" , l .Format )
6567 }
@@ -86,13 +88,14 @@ func (l *Config) Init() error {
8688
8789// DefaultLogFormatter delegates formatting to standard go log package
8890type DefaultLogFormatter struct {
91+ TimestampFormat string
8992}
9093
9194// Format formats the logrus entry by passing it to the "log" package
9295func (f * DefaultLogFormatter ) Format (entry * logrus.Entry ) ([]byte , error ) {
9396 b := & bytes.Buffer {}
9497 logger := log .New (b , "" , 0 )
95- logger .Println (time .Now ().Format (time . RFC3339Nano ) + " " + string (entry .Message ))
98+ logger .Println (time .Now ().Format (f . TimestampFormat ) + " " + string (entry .Message ))
9699 // Panic and Fatal are handled by logrus automatically
97100 return b .Bytes (), nil
98101}
You can’t perform that action at this time.
0 commit comments