Skip to content

Commit

Permalink
Configuring the logs by default in the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jespino committed Jul 2, 2021
1 parent 9edaa5e commit 01962a7
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion mattermost-plugin/server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (p *Plugin) OnActivate() error {
}

logger := mlog.NewLogger()
cfgJSON := defaultLoggingConfig()
err := logger.Configure("", cfgJSON)
if err != nil {
return err
}

server, err := server.New(&config.Configuration{
ServerRoot: *mmconfig.ServiceSettings.SiteURL + "/plugins/focalboard",
Expand Down Expand Up @@ -130,4 +135,29 @@ func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Req
router.ServeHTTP(w, r)
}

// See https://developers.mattermost.com/extend/plugins/server/reference/
func defaultLoggingConfig() string {
return `
{
"def": {
"type": "console",
"options": {
"out": "stdout"
},
"format": "plain",
"format_options": {
"delim": " ",
"min_level_len": 5,
"min_msg_len": 40,
"enable_color": true
},
"levels": [
{"id": 5, "name": "debug"},
{"id": 4, "name": "info", "color": 36},
{"id": 3, "name": "warn"},
{"id": 2, "name": "error", "color": 31},
{"id": 1, "name": "fatal", "stacktrace": true},
{"id": 0, "name": "panic", "stacktrace": true}
]
}
}`
}

0 comments on commit 01962a7

Please sign in to comment.