#680 use a local logger type

This commit is contained in:
JanErik Keller 2019-04-17 09:24:34 +02:00
parent 520bcb0500
commit a938e14793
2 changed files with 20 additions and 3 deletions

17
util.go
View file

@ -12,6 +12,7 @@ package viper
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -217,3 +218,19 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{}
} }
return m 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...) }

View file

@ -40,13 +40,13 @@ import (
"github.com/magiconair/properties" "github.com/magiconair/properties"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
toml "github.com/pelletier/go-toml" toml "github.com/pelletier/go-toml"
"github.com/sirupsen/logrus"
"github.com/spf13/afero" "github.com/spf13/afero"
"github.com/spf13/cast" "github.com/spf13/cast"
"github.com/spf13/pflag" "github.com/spf13/pflag"
) )
// Logger collects log messages. // Logger collects log messages. The default logger logs warnings,
// errors and fatals.
var Logger interface { var Logger interface {
Tracef(string, ...interface{}) Tracef(string, ...interface{})
Debugf(string, ...interface{}) Debugf(string, ...interface{})
@ -61,7 +61,7 @@ var Logger interface {
Warning(...interface{}) Warning(...interface{})
Error(...interface{}) Error(...interface{})
Fatal(...interface{}) Fatal(...interface{})
} = logrus.New() } = logger{}
// ConfigMarshalError happens when failing to marshal the configuration. // ConfigMarshalError happens when failing to marshal the configuration.
type ConfigMarshalError struct { type ConfigMarshalError struct {