From e538a4d30459e9da1a021400b5de85894b4efabc Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Sun, 2 Dec 2018 02:55:35 +0800 Subject: Update nlopes/slack to 4.1-dev (#595) --- vendor/github.com/nlopes/slack/logger.go | 59 ++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'vendor/github.com/nlopes/slack/logger.go') diff --git a/vendor/github.com/nlopes/slack/logger.go b/vendor/github.com/nlopes/slack/logger.go index 501d1672..6a3533a9 100644 --- a/vendor/github.com/nlopes/slack/logger.go +++ b/vendor/github.com/nlopes/slack/logger.go @@ -2,52 +2,59 @@ package slack import ( "fmt" - "sync" ) -// SetLogger let's library users supply a logger, so that api debugging -// can be logged along with the application's debugging info. -func SetLogger(l logProvider) { - loggerMutex.Lock() - logger = ilogger{logProvider: l} - loggerMutex.Unlock() -} - -var ( - loggerMutex = new(sync.Mutex) - logger logInternal // A logger that can be set by consumers -) - -// logProvider is a logger interface compatible with both stdlib and some -// 3rd party loggers such as logrus. -type logProvider interface { +// logger is a logger interface compatible with both stdlib and some +// 3rd party loggers. +type logger interface { Output(int, string) error } -// logInternal represents the internal logging api we use. -type logInternal interface { +// ilogger represents the internal logging api we use. +type ilogger interface { + logger Print(...interface{}) Printf(string, ...interface{}) Println(...interface{}) - Output(int, string) error } -// ilogger implements the additional methods used by our internal logging. -type ilogger struct { - logProvider +type debug interface { + Debug() bool + + // Debugf print a formatted debug line. + Debugf(format string, v ...interface{}) + // Debugln print a debug line. + Debugln(v ...interface{}) +} + +// internalLog implements the additional methods used by our internal logging. +type internalLog struct { + logger } // Println replicates the behaviour of the standard logger. -func (t ilogger) Println(v ...interface{}) { +func (t internalLog) Println(v ...interface{}) { t.Output(2, fmt.Sprintln(v...)) } // Printf replicates the behaviour of the standard logger. -func (t ilogger) Printf(format string, v ...interface{}) { +func (t internalLog) Printf(format string, v ...interface{}) { t.Output(2, fmt.Sprintf(format, v...)) } // Print replicates the behaviour of the standard logger. -func (t ilogger) Print(v ...interface{}) { +func (t internalLog) Print(v ...interface{}) { t.Output(2, fmt.Sprint(v...)) } + +type discard struct{} + +func (t discard) Debug() bool { + return false +} + +// Debugf print a formatted debug line. +func (t discard) Debugf(format string, v ...interface{}) {} + +// Debugln print a debug line. +func (t discard) Debugln(v ...interface{}) {} -- cgit v1.2.3