diff --git a/README.md b/README.md index 0e39601..f457193 100644 --- a/README.md +++ b/README.md @@ -321,10 +321,10 @@ The built-in logging formatters are: field to `true`. To force no colored output even if there is a TTY set the `DisableColors` field to `true` * `logrus.JSONFormatter`. Logs fields as JSON. -* `logrus.LogstashFormatter`. Logs fields as Logstash Events (http://logstash.net). +* `logrus_logstash.LogstashFormatter`. Logs fields as Logstash Events (http://logstash.net). ```go - logrus.SetFormatter(&logrus.LogstashFormatter{Type: “application_name"}) + logrus.SetFormatter(&logrus_logstash.LogstashFormatter{Type: “application_name"}) ``` Third party logging formatters: diff --git a/logstash_formatter.go b/formatters/logstash/logstash_formatter.go similarity index 87% rename from logstash_formatter.go rename to formatters/logstash/logstash_formatter.go index 99a3f7f..63ac133 100644 --- a/logstash_formatter.go +++ b/formatters/logstash/logstash_formatter.go @@ -1,8 +1,9 @@ -package logrus +package logrus_logstash import ( "encoding/json" "fmt" + "github.com/Sirupsen/logrus" "time" ) @@ -12,7 +13,7 @@ type LogstashFormatter struct { Type string // if not empty use for logstash type field. } -func (f *LogstashFormatter) Format(entry *Entry) ([]byte, error) { +func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error) { entry.Data["@version"] = 1 entry.Data["@timestamp"] = entry.Time.Format(time.RFC3339)