diff options
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...) +} |