summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/logger.go
diff options
context:
space:
mode:
authorPatrick Connolly <patrick.c.connolly@gmail.com>2018-12-02 02:55:35 +0800
committerWim <wim@42.be>2018-12-01 19:55:35 +0100
commite538a4d30459e9da1a021400b5de85894b4efabc (patch)
treeead4f82d5459fe0d3465f7e3656243cd613c07a6 /vendor/github.com/nlopes/slack/logger.go
parentf94c2b40a3e8eb45054bda1b71eb6fd3f9bc9e6d (diff)
downloadmatterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.gz
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.tar.bz2
matterbridge-msglm-e538a4d30459e9da1a021400b5de85894b4efabc.zip
Update nlopes/slack to 4.1-dev (#595)
Diffstat (limited to 'vendor/github.com/nlopes/slack/logger.go')
-rw-r--r--vendor/github.com/nlopes/slack/logger.go59
1 files changed, 33 insertions, 26 deletions
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{}) {}