evalphobia / logrus_appneta

AppNeta TraceView hooks for logrus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logrus_appneta

Build Status codecov GoDoc

AppNeta TraceView Hook for Logrus :walrus:

Usage

import (
	"github.com/Sirupsen/logrus"
	"github.com/evalphobia/logrus_appneta"
)

func main() {
	hook := logrus_appneta.NewHook()
	hook.SetLevels([]logrus.Level{
		logrus.PanicLevel,
		logrus.ErrorLevel,
	})

	logrus.AddHook(hook)
}

Special fields

Some logrus fields have a special meaning in this hook.

layer layer is tv.Layer type and used to send error. layer or context is required to send error.
context context is context.Context type and used to send error. layer or context is required to send error.
error error is error type and used for error message
error_class error_class is string type and used for error class name
layer_name layer_name is string type and used as a layer name. If this field is empty, AppnetaHook.LayerName is used as a layer name.

These field can have original prefix.

	hook := logrus_appneta.NewHook()
	hook.FieldPrefix = "your_prefix_"
	logrus.AddHook(hook)

About

AppNeta TraceView hooks for logrus

License:Apache License 2.0


Languages

Language:Go 100.0%