summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Sirupsen/logrus/json_formatter.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-02-20 23:41:09 +0100
committerWim <wim@42.be>2018-02-20 23:41:09 +0100
commit6ea368c383ccc19678623c51d8e4ecbbdb0a64ac (patch)
tree0ccce9d453a743c59abf58eb510ccab99128e381 /vendor/github.com/Sirupsen/logrus/json_formatter.go
parente92b6de09fd9d983deea17113b28aaba14863735 (diff)
downloadmatterbridge-msglm-6ea368c383ccc19678623c51d8e4ecbbdb0a64ac.tar.gz
matterbridge-msglm-6ea368c383ccc19678623c51d8e4ecbbdb0a64ac.tar.bz2
matterbridge-msglm-6ea368c383ccc19678623c51d8e4ecbbdb0a64ac.zip
Move Sirupsen => sirupsen
Diffstat (limited to 'vendor/github.com/Sirupsen/logrus/json_formatter.go')
-rw-r--r--vendor/github.com/Sirupsen/logrus/json_formatter.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/vendor/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/Sirupsen/logrus/json_formatter.go
deleted file mode 100644
index 266554e9..00000000
--- a/vendor/github.com/Sirupsen/logrus/json_formatter.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package logrus
-
-import (
- "encoding/json"
- "fmt"
-)
-
-type fieldKey string
-type FieldMap map[fieldKey]string
-
-const (
- FieldKeyMsg = "msg"
- FieldKeyLevel = "level"
- FieldKeyTime = "time"
-)
-
-func (f FieldMap) resolve(key fieldKey) string {
- if k, ok := f[key]; ok {
- return k
- }
-
- return string(key)
-}
-
-type JSONFormatter struct {
- // TimestampFormat sets the format used for marshaling timestamps.
- TimestampFormat string
-
- // DisableTimestamp allows disabling automatic timestamps in output
- DisableTimestamp bool
-
- // 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) {
- data := make(Fields, len(entry.Data)+3)
- for k, v := range entry.Data {
- switch v := v.(type) {
- case error:
- // Otherwise errors are ignored by `encoding/json`
- // https://github.com/Sirupsen/logrus/issues/137
- data[k] = v.Error()
- default:
- data[k] = v
- }
- }
- prefixFieldClashes(data)
-
- timestampFormat := f.TimestampFormat
- if timestampFormat == "" {
- timestampFormat = DefaultTimestampFormat
- }
-
- if !f.DisableTimestamp {
- data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
- }
- data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
- data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
-
- serialized, err := json.Marshal(data)
- if err != nil {
- return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
- }
- return append(serialized, '\n'), nil
-}