github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/app/plugin_api_tests/test_call_log_api_plugin/main.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package main
     5  
     6  import (
     7  	"github.com/pkg/errors"
     8  
     9  	"github.com/mattermost/mattermost-server/v5/model"
    10  	"github.com/mattermost/mattermost-server/v5/plugin"
    11  )
    12  
    13  type PluginUsingLogAPI struct {
    14  	plugin.MattermostPlugin
    15  }
    16  
    17  type Foo struct {
    18  	bar float64
    19  }
    20  
    21  func main() {
    22  	plugin.ClientMain(&PluginUsingLogAPI{})
    23  }
    24  
    25  func (p *PluginUsingLogAPI) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
    26  	p.API.LogDebug("LogDebug", "one", 1, "two", "two", "foo", Foo{bar: 3.1416})
    27  	p.API.LogInfo("LogInfo", "one", 1, "two", "two", "foo", Foo{bar: 3.1416})
    28  	p.API.LogWarn("LogWarn", "one", 1, "two", "two", "foo", Foo{bar: 3.1416})
    29  	p.API.LogError("LogError", "error", errors.WithStack(errors.New("boom!")))
    30  	return nil, "OK"
    31  }