mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
#680 use a local logger type
This commit is contained in:
parent
520bcb0500
commit
a938e14793
2 changed files with 20 additions and 3 deletions
17
util.go
17
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...) }
|
||||
|
|
6
viper.go
6
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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue