DisableColors in two tests to fix AppEngine configuration

This commit is contained in:
Mark Dittmer 2018-09-18 13:54:23 -04:00
parent 0a8fc8d77c
commit 629982b495
2 changed files with 7 additions and 3 deletions

View File

@ -1,14 +1,16 @@
package logrus_test package logrus_test
import ( import (
"github.com/sirupsen/logrus"
"os" "os"
"github.com/sirupsen/logrus"
) )
func Example_basic() { func Example_basic() {
var log = logrus.New() var log = logrus.New()
log.Formatter = new(logrus.JSONFormatter) log.Formatter = new(logrus.JSONFormatter)
log.Formatter = new(logrus.TextFormatter) //default 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.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
log.Level = logrus.DebugLevel log.Level = logrus.DebugLevel
log.Out = os.Stdout log.Out = os.Stdout

View File

@ -3,16 +3,18 @@
package logrus_test package logrus_test
import ( import (
"github.com/sirupsen/logrus"
slhooks "github.com/sirupsen/logrus/hooks/syslog"
"log/syslog" "log/syslog"
"os" "os"
"github.com/sirupsen/logrus"
slhooks "github.com/sirupsen/logrus/hooks/syslog"
) )
// An example on how to use a hook // An example on how to use a hook
func Example_hook() { func Example_hook() {
var log = logrus.New() var log = logrus.New()
log.Formatter = new(logrus.TextFormatter) // default 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.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
if sl, err := slhooks.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, ""); err != nil { if sl, err := slhooks.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, ""); err != nil {
log.Hooks.Add(sl) log.Hooks.Add(sl)