From da474fcc776b9b3829e57f796b78237a00923367 Mon Sep 17 00:00:00 2001 From: Guoqiang Chen Date: Thu, 17 May 2018 15:04:05 +0000 Subject: [PATCH] Fixes build issue --- formatters/json_formatter.go | 4 ++-- formatters/text_formatter.go | 3 +-- formatters/util_terminal.go | 3 +++ logger_test.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/formatters/json_formatter.go b/formatters/json_formatter.go index fcc75c7..d08b9a8 100644 --- a/formatters/json_formatter.go +++ b/formatters/json_formatter.go @@ -52,11 +52,11 @@ func (f JSONFormatter) Format(level log.Level, msg string, logger *log.Logger) [ data["line"] = line data["msg"] = msg - line, err := marshal(data) + serialized, err := marshal(data) if err != nil { fmt.Fprintf(os.Stderr, "Failed to marshal json, %v\n", err) } - return line + return serialized } func marshal(v interface{}) ([]byte, error) { diff --git a/formatters/text_formatter.go b/formatters/text_formatter.go index 9c74022..be05ce2 100644 --- a/formatters/text_formatter.go +++ b/formatters/text_formatter.go @@ -2,7 +2,6 @@ package formatters import ( "bytes" - "io" "os" "path/filepath" "strconv" @@ -49,7 +48,7 @@ func (f TextFormatter) Format(level log.Level, msg string, logger *log.Logger) [ f.isterm = IsTerminal(logger.Out) - host, _ = os.Hostname() + host, _ := os.Hostname() f.host = []byte(host) f.pid = []byte(strconv.Itoa(os.Getpid())) diff --git a/formatters/util_terminal.go b/formatters/util_terminal.go index 83c1347..2008e22 100644 --- a/formatters/util_terminal.go +++ b/formatters/util_terminal.go @@ -1,6 +1,9 @@ package formatters import ( + "io" + "os" + "golang.org/x/crypto/ssh/terminal" ) diff --git a/logger_test.go b/logger_test.go index 14b5f4c..b020343 100644 --- a/logger_test.go +++ b/logger_test.go @@ -107,7 +107,7 @@ func TestLogOnLevel(t *testing.T) { for i, tt := range tests { func() { defer func() { - // check panic hits + // check panic hits if err := recover(); err != nil { if !tt.fns.ispanic { t.Errorf("Case %d, got panic", i)