Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate logging to use RPC Logging methods #102

Merged
merged 11 commits into from
Mar 27, 2020
3 changes: 1 addition & 2 deletions server/autolinkplugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/mattermost/mattermost-plugin-autolink/server/autolink"
"github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model"
)

Expand All @@ -28,7 +27,7 @@ func (p *Plugin) OnConfigurationChange() error {
for i := range c.Links {
err = c.Links[i].Compile()
if err != nil {
mlog.Error(fmt.Sprintf("Error creating autolinker: %+v: %v", c.Links[i], err))
p.API.LogError(fmt.Sprintf("Error creating autolinker: %+v: %v", c.Links[i], err))
mo2menelzeiny marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
8 changes: 4 additions & 4 deletions server/autolinkplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ func (p *Plugin) ProcessPost(c *plugin.Context, post *model.Post) (*model.Post,
startPos, endPos = autolinkNode.RawDestination.Position+offset, autolinkNode.RawDestination.End+offset
origText = postText[startPos:endPos]
if autolinkNode.Destination() != origText {
mlog.Error(fmt.Sprintf("Markdown autolink did not match range text, '%s' != '%s'", autolinkNode.Destination(), origText))
p.API.LogError(fmt.Sprintf("Markdown autolink did not match range text, '%s' != '%s'", autolinkNode.Destination(), origText))
return true
}
} else if textNode, ok := node.(*markdown.Text); ok {
startPos, endPos = textNode.Range.Position+offset, textNode.Range.End+offset
origText = postText[startPos:endPos]
if textNode.Text != origText {
mlog.Error(fmt.Sprintf("Markdown text did not match range text, '%s' != '%s'", textNode.Text, origText))
p.API.LogError(fmt.Sprintf("Markdown text did not match range text, '%s' != '%s'", textNode.Text, origText))
return true
}
}
Expand All @@ -103,14 +103,14 @@ func (p *Plugin) ProcessPost(c *plugin.Context, post *model.Post) (*model.Post,

channel, cErr := p.API.GetChannel(post.ChannelId)
if cErr != nil {
mlog.Error(cErr.Error())
p.API.LogError(cErr.Error())
mo2menelzeiny marked this conversation as resolved.
Show resolved Hide resolved
return false
}
teamName := ""
if channel.TeamId != "" {
team, tErr := p.API.GetTeam(channel.TeamId)
if tErr != nil {
mlog.Error(tErr.Error())
p.API.LogError(tErr.Error())
return false
}
teamName = team.Name
Expand Down