etwlogrus

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 4 Imported by: 13

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

View Source
var ErrNoProvider = errors.New("no ETW registered provider")

ErrNoProvider is returned when a hook is created without a provider being configured.

Functions

This section is empty.

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook is a Logrus hook which logs received events to ETW.

func NewHook

func NewHook(providerName string, opts ...HookOpt) (*Hook, error)

NewHook registers a new ETW provider and returns a hook to log from it. The provider will be closed when the hook is closed.

func NewHookFromOpts added in v0.6.0

func NewHookFromOpts(opts ...HookOpt) (*Hook, error)

NewHookFromOpts creates a new hook with the provided options. An error is returned if the hook does not have a valid provider.

func NewHookFromProvider added in v0.4.13

func NewHookFromProvider(provider *etw.Provider, opts ...HookOpt) (*Hook, error)

NewHookFromProvider creates a new hook based on an existing ETW provider. The provider will not be closed when the hook is closed.

func (*Hook) Close

func (h *Hook) Close() error

Close cleans up the hook and closes the ETW provider. If the provder was registered by etwlogrus, it will be closed as part of `Close`. If the provider was passed in, it will not be closed.

func (*Hook) Fire

func (h *Hook) Fire(e *logrus.Entry) error

Fire receives each Logrus entry as it is logged, and logs it to ETW.

func (*Hook) Levels

func (*Hook) Levels() []logrus.Level

Levels returns the set of levels that this hook wants to receive log entries for.

type HookOpt added in v0.6.0

type HookOpt func(*Hook) error

HookOpt is an option to change the behavior of the Logrus ETW hook.

func WithEventOpts added in v0.6.0

func WithEventOpts(f func(*logrus.Entry) []etw.EventOpt) HookOpt

WithEventOpts allows additional ETW event properties (keywords, tags, etc.) to be specified.

func WithExistingETWProvider added in v0.6.0

func WithExistingETWProvider(p *etw.Provider) HookOpt

WithExistingETWProvider configures the hook to use an existing ETW provider. The provider will not be closed when the hook is closed.

func WithGetName added in v0.6.0

func WithGetName(f func(*logrus.Entry) string) HookOpt

WithGetName sets the ETW EventName of an event to the value returned by f If the name is empty, the default event name will be used.

func WithNewETWProvider added in v0.6.0

func WithNewETWProvider(n string) HookOpt

WithNewETWProvider registers a new ETW provider and sets the hook to log using it. The provider will be closed when the hook is closed.

Jump to

Keyboard shortcuts

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