mirror of https://github.com/docker/docs.git
Extract interface and Remove log.print
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
parent
7f499308fc
commit
109bea4151
|
|
@ -244,7 +244,7 @@ func detectShell() (string, error) {
|
||||||
if shell == "" {
|
if shell == "" {
|
||||||
// check for windows env and not bash (i.e. msysgit, etc)
|
// check for windows env and not bash (i.e. msysgit, etc)
|
||||||
if runtime.GOOS == "windows" {
|
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
|
return "", ErrUnknownShell
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
@ -6,33 +6,6 @@ import (
|
||||||
"sync"
|
"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 (
|
var (
|
||||||
l = StandardLogger{
|
l = StandardLogger{
|
||||||
mu: &sync.Mutex{},
|
mu: &sync.Mutex{},
|
||||||
|
|
@ -97,14 +70,6 @@ func Fatalf(fmtString string, args ...interface{}) {
|
||||||
l.Fatalf(fmtString, args...)
|
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{}) {
|
func Warn(args ...interface{}) {
|
||||||
l.Warn(args...)
|
l.Warn(args...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,14 +94,6 @@ func (t StandardLogger) Fatalf(fmtString string, args ...interface{}) {
|
||||||
os.Exit(1)
|
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{}) {
|
func (t StandardLogger) Warn(args ...interface{}) {
|
||||||
fmt.Print("WARNING >>> ")
|
fmt.Print("WARNING >>> ")
|
||||||
t.log(args...)
|
t.log(args...)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue