Skip to content

evalphobia/logrus_appneta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)