diff options
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/json_formatter.go')
-rw-r--r-- | vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/json_formatter.go | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/json_formatter.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/json_formatter.go deleted file mode 100644 index 2ad6dc5..0000000 --- a/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/json_formatter.go +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | package logrus | ||
2 | |||
3 | import ( | ||
4 | "encoding/json" | ||
5 | "fmt" | ||
6 | ) | ||
7 | |||
8 | type JSONFormatter struct { | ||
9 | // TimestampFormat sets the format used for marshaling timestamps. | ||
10 | TimestampFormat string | ||
11 | } | ||
12 | |||
13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { | ||
14 | data := make(Fields, len(entry.Data)+3) | ||
15 | for k, v := range entry.Data { | ||
16 | switch v := v.(type) { | ||
17 | case error: | ||
18 | // Otherwise errors are ignored by `encoding/json` | ||
19 | // https://github.com/Sirupsen/logrus/issues/137 | ||
20 | data[k] = v.Error() | ||
21 | default: | ||
22 | data[k] = v | ||
23 | } | ||
24 | } | ||
25 | prefixFieldClashes(data) | ||
26 | |||
27 | timestampFormat := f.TimestampFormat | ||
28 | if timestampFormat == "" { | ||
29 | timestampFormat = DefaultTimestampFormat | ||
30 | } | ||
31 | |||
32 | data["time"] = entry.Time.Format(timestampFormat) | ||
33 | data["msg"] = entry.Message | ||
34 | data["level"] = entry.Level.String() | ||
35 | |||
36 | serialized, err := json.Marshal(data) | ||
37 | if err != nil { | ||
38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) | ||
39 | } | ||
40 | return append(serialized, '\n'), nil | ||
41 | } | ||