mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
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
This commit is contained in:
committed by
GitHub
parent
3848cb7e79
commit
83a3ac089c
@@ -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...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user