From 90501cfcc53d8ff36297203d6e8e0653da98f7d1 Mon Sep 17 00:00:00 2001 From: Mark Dittmer Date: Mon, 17 Sep 2018 13:50:48 -0400 Subject: [PATCH 1/4] Fix AppEngine builds `go build -tags appengine [...]` currently yields: ``` .../github.com/sirupsen/logrus/text_formatter.go:84:4: undefined: initTerminal ``` This change implements `initTerminal` for AppEngine builds. --- terminal_appengine.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 terminal_appengine.go diff --git a/terminal_appengine.go b/terminal_appengine.go new file mode 100644 index 0000000..2f34402 --- /dev/null +++ b/terminal_appengine.go @@ -0,0 +1,11 @@ +// Based on ssh/terminal: +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appengine + +package logrus + +func initTerminal(w io.Writer) { +} From f1ce1baf5623907d7056fc71a6e4232447f01cc5 Mon Sep 17 00:00:00 2001 From: Mark Dittmer Date: Mon, 17 Sep 2018 13:52:43 -0400 Subject: [PATCH 2/4] Fix copypasta --- terminal_appengine.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/terminal_appengine.go b/terminal_appengine.go index 2f34402..72f679c 100644 --- a/terminal_appengine.go +++ b/terminal_appengine.go @@ -1,5 +1,5 @@ // Based on ssh/terminal: -// Copyright 2013 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -7,5 +7,7 @@ package logrus +import "io" + func initTerminal(w io.Writer) { } From 0a8fc8d77cebf6bb58f90fe8a934a3b516b9e5bd Mon Sep 17 00:00:00 2001 From: Mark Dittmer Date: Mon, 17 Sep 2018 13:56:18 -0400 Subject: [PATCH 3/4] Add AppEngine test configurations to travis to a void regression --- .travis.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.travis.yml b/.travis.yml index dd1218c..1f953be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,3 +26,26 @@ matrix: - go get golang.org/x/sys/windows script: - go test -race -v ./... + - go: 1.10.x + install: + - go get github.com/stretchr/testify/assert + - go get golang.org/x/crypto/ssh/terminal + - go get golang.org/x/sys/unix + - go get golang.org/x/sys/windows + script: + - go test -race -v -tags appengine ./... + - go: 1.11.x + env: GO111MODULE=on + install: + - go mod download + script: + - go test -race -v -tags appengine ./... + - go: 1.11.x + env: GO111MODULE=off + install: + - go get github.com/stretchr/testify/assert + - go get golang.org/x/crypto/ssh/terminal + - go get golang.org/x/sys/unix + - go get golang.org/x/sys/windows + script: + - go test -race -v -tags appengine ./... From 629982b4957da4679c12227a2b3d09dd42f659d2 Mon Sep 17 00:00:00 2001 From: Mark Dittmer Date: Tue, 18 Sep 2018 13:54:23 -0400 Subject: [PATCH 4/4] DisableColors in two tests to fix AppEngine configuration --- example_basic_test.go | 4 +++- example_hook_test.go | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/example_basic_test.go b/example_basic_test.go index a2acf55..5f3849b 100644 --- a/example_basic_test.go +++ b/example_basic_test.go @@ -1,14 +1,16 @@ package logrus_test import ( - "github.com/sirupsen/logrus" "os" + + "github.com/sirupsen/logrus" ) func Example_basic() { var log = logrus.New() log.Formatter = new(logrus.JSONFormatter) log.Formatter = new(logrus.TextFormatter) //default + log.Formatter.(*logrus.TextFormatter).DisableColors = true // remove colors log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output log.Level = logrus.DebugLevel log.Out = os.Stdout diff --git a/example_hook_test.go b/example_hook_test.go index 28bd8ea..15118d2 100644 --- a/example_hook_test.go +++ b/example_hook_test.go @@ -3,16 +3,18 @@ package logrus_test import ( - "github.com/sirupsen/logrus" - slhooks "github.com/sirupsen/logrus/hooks/syslog" "log/syslog" "os" + + "github.com/sirupsen/logrus" + slhooks "github.com/sirupsen/logrus/hooks/syslog" ) // An example on how to use a hook func Example_hook() { var log = logrus.New() log.Formatter = new(logrus.TextFormatter) // default + log.Formatter.(*logrus.TextFormatter).DisableColors = true // remove colors log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output if sl, err := slhooks.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, ""); err != nil { log.Hooks.Add(sl)