hooks

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package hooks provide hooks and integration for otelgo to various logging library.

Currently only `github.com/sirupsen/logrus` is supported. See NewLogrusHook().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogrusHook

func NewLogrusHook(options ...LogrusOption) logrus.Hook

NewLogrusHook creates a new logrus.Hook that will export all logrus.Entry to the global otelog registered LogExporter. By default no levels are enabled, and must be set with FromLogrusLevel or WithLogrusLevels.

If a context.Context containing a valid otel.SpanContext is provided to the logrus.Entry, the exported LogRecord will be automatically linked with the span.

Types

type LogrusOption

type LogrusOption interface {
	// contains filtered or unexported methods
}

LogrusOption is an option for NewLogrusHook()

func FromLogrusLevel

func FromLogrusLevel(level logrus.Level) LogrusOption

FromLogrusLevel enables all levels from the specified level. By example `logrus.WarnLevel` will enable `logrus.WarnLevel` `logrus.ErrorLevel` `logrus.FatalLevel` and `logrus.PanicLevel`

func WithLogrusLevels

func WithLogrusLevels(levels []logrus.Level) LogrusOption

WithLogrusLevels enables all provided levels for the hook.

Jump to

Keyboard shortcuts

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