Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.54 KB

README.md

File metadata and controls

48 lines (35 loc) · 1.54 KB

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)