summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/bwmarrin/discordgo/logging.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-02-14 22:22:35 +0100
committerWim <wim@42.be>2018-02-14 22:22:35 +0100
commitfd0fe3390b3c57da329aeda014e87f9a0a6f7fc0 (patch)
treef3c4e5eca8b16d27c6def1d17053b6a6db1d79c0 /vendor/github.com/bwmarrin/discordgo/logging.go
parent2522158127d2d55c992ddd2201e19de1907b0f67 (diff)
downloadmatterbridge-msglm-fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0.tar.gz
matterbridge-msglm-fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0.tar.bz2
matterbridge-msglm-fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0.zip
Update vendor bwmarrin/discordgo
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/logging.go')
-rw-r--r--vendor/github.com/bwmarrin/discordgo/logging.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/logging.go b/vendor/github.com/bwmarrin/discordgo/logging.go
index 70d78d60..6460b35b 100644
--- a/vendor/github.com/bwmarrin/discordgo/logging.go
+++ b/vendor/github.com/bwmarrin/discordgo/logging.go
@@ -23,7 +23,7 @@ const (
LogError int = iota
// LogWarning level is used for very abnormal events and errors that are
- // also returend to a calling function.
+ // also returned to a calling function.
LogWarning
// LogInformational level is used for normal non-error activity
@@ -34,26 +34,34 @@ const (
LogDebug
)
+// Logger can be used to replace the standard logging for discordgo
+var Logger func(msgL, caller int, format string, a ...interface{})
+
// msglog provides package wide logging consistancy for discordgo
// the format, a... portion this command follows that of fmt.Printf
// msgL : LogLevel of the message
// caller : 1 + the number of callers away from the message source
// format : Printf style message format
-// a ... : comma seperated list of values to pass
+// a ... : comma separated list of values to pass
func msglog(msgL, caller int, format string, a ...interface{}) {
- pc, file, line, _ := runtime.Caller(caller)
+ if Logger != nil {
+ Logger(msgL, caller, format, a...)
+ } else {
+
+ pc, file, line, _ := runtime.Caller(caller)
- files := strings.Split(file, "/")
- file = files[len(files)-1]
+ files := strings.Split(file, "/")
+ file = files[len(files)-1]
- name := runtime.FuncForPC(pc).Name()
- fns := strings.Split(name, ".")
- name = fns[len(fns)-1]
+ name := runtime.FuncForPC(pc).Name()
+ fns := strings.Split(name, ".")
+ name = fns[len(fns)-1]
- msg := fmt.Sprintf(format, a...)
+ msg := fmt.Sprintf(format, a...)
- log.Printf("[DG%d] %s:%d:%s() %s\n", msgL, file, line, name, msg)
+ log.Printf("[DG%d] %s:%d:%s() %s\n", msgL, file, line, name, msg)
+ }
}
// helper function that wraps msglog for the Session struct