summaryrefslogtreecommitdiffstats
path: root/plugin/hclog_adapter.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-07-03 09:58:28 -0700
committerGitHub <noreply@github.com>2018-07-03 09:58:28 -0700
commit83a3ac089cff0d05559e6ba5c2c60b09f5cae176 (patch)
tree51cc53c0a77cf455cf9d700a453b6d57f1604fdb /plugin/hclog_adapter.go
parent3848cb7e79e019e2f0878d6e2377ad36b3c7ca43 (diff)
downloadchat-83a3ac089cff0d05559e6ba5c2c60b09f5cae176.tar.gz
chat-83a3ac089cff0d05559e6ba5c2c60b09f5cae176.tar.bz2
chat-83a3ac089cff0d05559e6ba5c2c60b09f5cae176.zip
MM-11029 Adding plugin logging functionality. (#9034)
* Capturing stdout, stderr of plugins in logs. * Cleanup go-plugin debug logs. * Adding logging to plugin API * Generating mocks. * godoc convention
Diffstat (limited to 'plugin/hclog_adapter.go')
-rw-r--r--plugin/hclog_adapter.go36
1 files changed, 31 insertions, 5 deletions
diff --git a/plugin/hclog_adapter.go b/plugin/hclog_adapter.go
index c8e39877e..55d60f508 100644
--- a/plugin/hclog_adapter.go
+++ b/plugin/hclog_adapter.go
@@ -6,6 +6,7 @@ package plugin
import (
"fmt"
"log"
+ "strings"
"github.com/hashicorp/go-hclog"
"github.com/mattermost/mattermost-server/mlog"
@@ -17,23 +18,48 @@ type HclogAdapter struct {
}
func (h *HclogAdapter) Trace(msg string, args ...interface{}) {
- h.wrappedLogger.Debug(msg, mlog.String(h.extrasKey, fmt.Sprintln(args...)))
+ extras := strings.TrimSpace(fmt.Sprint(args...))
+ if extras != "" {
+ h.wrappedLogger.Debug(msg, mlog.String(h.extrasKey, extras))
+ } else {
+ h.wrappedLogger.Debug(msg)
+ }
}
func (h *HclogAdapter) Debug(msg string, args ...interface{}) {
- h.wrappedLogger.Debug(msg, mlog.String(h.extrasKey, fmt.Sprintln(args...)))
+ extras := strings.TrimSpace(fmt.Sprint(args...))
+ if extras != "" {
+ h.wrappedLogger.Debug(msg, mlog.String(h.extrasKey, extras))
+ } else {
+ h.wrappedLogger.Debug(msg)
+ }
}
func (h *HclogAdapter) Info(msg string, args ...interface{}) {
- h.wrappedLogger.Info(msg, mlog.String(h.extrasKey, fmt.Sprintln(args...)))
+ extras := strings.TrimSpace(fmt.Sprint(args...))
+ if extras != "" {
+ h.wrappedLogger.Info(msg, mlog.String(h.extrasKey, extras))
+ } else {
+ h.wrappedLogger.Info(msg)
+ }
}
func (h *HclogAdapter) Warn(msg string, args ...interface{}) {
- h.wrappedLogger.Warn(msg, mlog.String(h.extrasKey, fmt.Sprintln(args...)))
+ extras := strings.TrimSpace(fmt.Sprint(args...))
+ if extras != "" {
+ h.wrappedLogger.Warn(msg, mlog.String(h.extrasKey, extras))
+ } else {
+ h.wrappedLogger.Warn(msg)
+ }
}
func (h *HclogAdapter) Error(msg string, args ...interface{}) {
- h.wrappedLogger.Error(msg, mlog.String(h.extrasKey, fmt.Sprintln(args...)))
+ extras := strings.TrimSpace(fmt.Sprint(args...))
+ if extras != "" {
+ h.wrappedLogger.Error(msg, mlog.String(h.extrasKey, extras))
+ } else {
+ h.wrappedLogger.Error(msg)
+ }
}
func (h *HclogAdapter) IsTrace() bool {