Extract interface and Remove log.print

Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
Jean-Laurent de Morlhon 2015-12-03 15:31:09 +01:00
parent 7f499308fc
commit 109bea4151
4 changed files with 21 additions and 44 deletions

View File

@ -244,7 +244,7 @@ func detectShell() (string, error) {
if shell == "" {
// check for windows env and not bash (i.e. msysgit, etc)
if runtime.GOOS == "windows" {
log.Printf("On Windows, please specify either 'cmd' or 'powershell' with the --shell flag.\n\n")
log.Infof("On Windows, please specify either 'cmd' or 'powershell' with the --shell flag.\n\n")
}
return "", ErrUnknownShell

View File

@ -0,0 +1,20 @@
package log
type Logger interface {
Debug(...interface{})
Debugf(string, ...interface{})
Info(...interface{})
Infof(string, ...interface{})
Warn(...interface{})
Warnf(string, ...interface{})
Error(...interface{})
Errorf(string, ...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
WithFields(Fields) Logger
}

View File

@ -6,33 +6,6 @@ import (
"sync"
)
// Logger - Why the interface? We may only want to print to STDOUT and STDERR for now,
// but it won't neccessarily be that way forever. This interface is intended
// to provide a "framework" for a variety of different logging types in the
// future (log to file, log to logstash, etc.) There could be a driver model
// similar to what is done with OS or machine providers.
type Logger interface {
Debug(...interface{})
Debugf(string, ...interface{})
Error(...interface{})
Errorf(string, ...interface{})
Info(...interface{})
Infof(string, ...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Print(...interface{})
Printf(string, ...interface{})
Warn(...interface{})
Warnf(string, ...interface{})
WithFields(Fields) Logger
}
var (
l = StandardLogger{
mu: &sync.Mutex{},
@ -97,14 +70,6 @@ func Fatalf(fmtString string, args ...interface{}) {
l.Fatalf(fmtString, args...)
}
func Print(args ...interface{}) {
l.Print(args...)
}
func Printf(fmtString string, args ...interface{}) {
l.Printf(fmtString, args...)
}
func Warn(args ...interface{}) {
l.Warn(args...)
}

View File

@ -94,14 +94,6 @@ func (t StandardLogger) Fatalf(fmtString string, args ...interface{}) {
os.Exit(1)
}
func (t StandardLogger) Print(args ...interface{}) {
t.log(args...)
}
func (t StandardLogger) Printf(fmtString string, args ...interface{}) {
t.logf(fmtString, args...)
}
func (t StandardLogger) Warn(args ...interface{}) {
fmt.Print("WARNING >>> ")
t.log(args...)