sls

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

sls

example
hooks {
       expander {}

       sls {
            endpoint = "cn-beijing.log.aliyuncs.com"
            access-key-id = ""
            access-key-secret = ""

            project = gogap   # sls project name
            store = test      # default log store name

            levels = ["debug","info","error","warn"] # these level's logs will post to sls

            fields {
            	store = "store"    # you could use WithField("store","test2") to specfic the store, orelse use default
                topic = "err_ns"   # you could use WithField("err_ns","this-is-topic") to specfic the topic
                source = "source"  # you could use WithField("source","this-is-soure") to specfic the source
                tags = "tags"      # you could use WithField("tags", map[string]string{"k","v"}) to specfic the tags
                context ="err_ctx" # you could use WithField("err_ctx", string|interface{}) to specfic the context
            }
       }

}
mikeLoger.WithError(e).WithField("source", "IAMSOURCE").WithField("store", "test2").Errorln("hello with gogap errors")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSLSHook

func NewSLSHook(config config.Configuration) (hook logrus.Hook, err error)

Types

type SLSHook

type SLSHook struct {
	AcceptedLevels []logrus.Level
	Config         SLSHookConfig
	// contains filtered or unexported fields
}

func (*SLSHook) Fire

func (p *SLSHook) Fire(entry *logrus.Entry) (err error)

Fire - Sent event to sls

func (*SLSHook) Levels

func (p *SLSHook) Levels() []logrus.Level

Levels sets which levels to sent to sls

type SLSHookConfig

type SLSHookConfig struct {
	Endpoint        string
	AccessKeyID     string
	AccessKeySecret string

	Project string
	Store   string

	StoreField   string
	TopicField   string
	SourceField  string
	TagsField    string
	ContextField string

	Levels []string
	Async  bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL