From a938e147935952f0861af560c0e9a02a3b89764b Mon Sep 17 00:00:00 2001 From: JanErik Keller Date: Wed, 17 Apr 2019 09:24:34 +0200 Subject: [PATCH] #680 use a local logger type --- util.go | 17 +++++++++++++++++ viper.go | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/util.go b/util.go index 11baffe..fb2a0ca 100644 --- a/util.go +++ b/util.go @@ -12,6 +12,7 @@ package viper import ( "fmt" + "log" "os" "path/filepath" "runtime" @@ -217,3 +218,19 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{} } return m } + +type logger struct{} + +func (logger) Tracef(f string, args ...interface{}) {} +func (logger) Debugf(f string, args ...interface{}) {} +func (logger) Infof(f string, args ...interface{}) {} +func (logger) Warningf(f string, args ...interface{}) { log.Printf(f, args...) } +func (logger) Errorf(f string, args ...interface{}) { log.Printf(f, args...) } +func (logger) Fatalf(f string, args ...interface{}) { log.Fatalf(f, args...) } + +func (logger) Trace(args ...interface{}) {} +func (logger) Debug(args ...interface{}) {} +func (logger) Info(args ...interface{}) {} +func (logger) Warning(args ...interface{}) { log.Print(args...) } +func (logger) Error(args ...interface{}) { log.Print(args...) } +func (logger) Fatal(args ...interface{}) { log.Fatal(args...) } diff --git a/viper.go b/viper.go index cb9e2da..7da0981 100644 --- a/viper.go +++ b/viper.go @@ -40,13 +40,13 @@ import ( "github.com/magiconair/properties" "github.com/mitchellh/mapstructure" toml "github.com/pelletier/go-toml" - "github.com/sirupsen/logrus" "github.com/spf13/afero" "github.com/spf13/cast" "github.com/spf13/pflag" ) -// Logger collects log messages. +// Logger collects log messages. The default logger logs warnings, +// errors and fatals. var Logger interface { Tracef(string, ...interface{}) Debugf(string, ...interface{}) @@ -61,7 +61,7 @@ var Logger interface { Warning(...interface{}) Error(...interface{}) Fatal(...interface{}) -} = logrus.New() +} = logger{} // ConfigMarshalError happens when failing to marshal the configuration. type ConfigMarshalError struct {