diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-07-03 09:58:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-03 09:58:28 -0700 |
commit | 83a3ac089cff0d05559e6ba5c2c60b09f5cae176 (patch) | |
tree | 51cc53c0a77cf455cf9d700a453b6d57f1604fdb /app/plugin_api.go | |
parent | 3848cb7e79e019e2f0878d6e2377ad36b3c7ca43 (diff) | |
download | chat-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 'app/plugin_api.go')
-rw-r--r-- | app/plugin_api.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/app/plugin_api.go b/app/plugin_api.go index fc786202e..714ffa700 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -7,18 +7,21 @@ import ( "encoding/json" "fmt" + "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" ) type PluginAPI struct { - id string - app *App + id string + app *App + logger *mlog.SugarLogger } func NewPluginAPI(a *App, manifest *model.Manifest) *PluginAPI { return &PluginAPI{ - id: manifest.Id, - app: a, + id: manifest.Id, + app: a, + logger: a.Log.With(mlog.String("plugin_id", manifest.Id)).Sugar(), } } @@ -185,3 +188,16 @@ func (api *PluginAPI) PublishWebSocketEvent(event string, payload map[string]int Broadcast: broadcast, }) } + +func (api *PluginAPI) LogDebug(msg string, keyValuePairs ...interface{}) { + api.logger.Debug(msg, keyValuePairs...) +} +func (api *PluginAPI) LogInfo(msg string, keyValuePairs ...interface{}) { + api.logger.Info(msg, keyValuePairs...) +} +func (api *PluginAPI) LogError(msg string, keyValuePairs ...interface{}) { + api.logger.Error(msg, keyValuePairs...) +} +func (api *PluginAPI) LogWarn(msg string, keyValuePairs ...interface{}) { + api.logger.Warn(msg, keyValuePairs...) +} |