From 3cc6fcc52194ca551e2a153f07eceb98c1d1ea66 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Thu, 5 Mar 2015 23:31:39 +0600 Subject: [PATCH] use formatters directory --- README.md | 4 ++-- .../logstash/logstash_formatter.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) rename logstash_formatter.go => formatters/logstash/logstash_formatter.go (87%) 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)