From fd0fe3390b3c57da329aeda014e87f9a0a6f7fc0 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 14 Feb 2018 22:22:35 +0100 Subject: Update vendor bwmarrin/discordgo --- vendor/github.com/bwmarrin/discordgo/logging.go | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'vendor/github.com/bwmarrin/discordgo/logging.go') 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 -- cgit v1.2.3