From 7498110889c70a447fdef7fa2d3903c8de92a602 Mon Sep 17 00:00:00 2001 From: Anton Tiurin Date: Tue, 10 Mar 2015 18:56:16 +0300 Subject: [PATCH 1/3] Remove unused regexp --- text_formatter.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index 71dcb66..0a06a11 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -3,7 +3,6 @@ package logrus import ( "bytes" "fmt" - "regexp" "sort" "strings" "time" @@ -21,7 +20,6 @@ const ( var ( baseTimestamp time.Time isTerminal bool - noQuoteNeeded *regexp.Regexp ) func init() { From 98fd21de2cae4ee1166e6aeb69aaa411dcb23c8d Mon Sep 17 00:00:00 2001 From: Anton Tiurin Date: Tue, 10 Mar 2015 19:04:57 +0300 Subject: [PATCH 2/3] [JSON] Use type-switch for error field --- json_formatter.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/json_formatter.go b/json_formatter.go index 0e38a61..5c4c44b 100644 --- a/json_formatter.go +++ b/json_formatter.go @@ -11,11 +11,12 @@ type JSONFormatter struct{} func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data := make(Fields, len(entry.Data)+3) for k, v := range entry.Data { - // Otherwise errors are ignored by `encoding/json` - // https://github.com/Sirupsen/logrus/issues/137 - if err, ok := v.(error); ok { - data[k] = err.Error() - } else { + 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 } } From a8b793a1fce082169f0d1f735ab1a3b63261398c Mon Sep 17 00:00:00 2001 From: Anton Tiurin Date: Tue, 10 Mar 2015 19:06:14 +0300 Subject: [PATCH 3/3] gofmt --- terminal_openbsd.go | 1 - writer.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/terminal_openbsd.go b/terminal_openbsd.go index d238bfa..af609a5 100644 --- a/terminal_openbsd.go +++ b/terminal_openbsd.go @@ -1,4 +1,3 @@ - package logrus import "syscall" diff --git a/writer.go b/writer.go index 90d3e01..1e30b1c 100644 --- a/writer.go +++ b/writer.go @@ -6,7 +6,7 @@ import ( "runtime" ) -func (logger *Logger) Writer() (*io.PipeWriter) { +func (logger *Logger) Writer() *io.PipeWriter { reader, writer := io.Pipe() go logger.writerScanner(reader)