loggerwr

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package loggerwr provides a wrapper for RBLs that implements a logging system.

This package is a work in progress and makes no API stability promises.

Index

Constants

View Source
const WrapperClass = "logger"

WrapperClass registered.

Variables

This section is empty.

Functions

func Builder

func Builder(defaultCfg Config) xlistd.BuildWrapperFn

Builder returns a builder function.

Types

type Config

type Config struct {
	Prefix   string
	Rules    Rules
	ShowPeer bool
}

Config options.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration.

type LogLevel

type LogLevel int

LogLevel defines LogLevel for rules.

const (
	Disable LogLevel = iota
	Debug
	Info
	Warn
	Error
)

Values for LogLevel.

func StringToLevel

func StringToLevel(s string) (LogLevel, error)

StringToLevel returns the loglevel.

type Logger

type Logger interface {
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
}

Logger defines the interface for the logger

type Rules

type Rules struct {
	Found    LogLevel
	NotFound LogLevel
	Error    LogLevel
}

Rules defines log levels for each event.

type Wrapper

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

Wrapper implements a logger for list checkers.

func New

func New(list xlistd.List, logger yalogi.Logger, cfg Config) *Wrapper

New creates a logger wrapper with preffix.

func (*Wrapper) Check

func (w *Wrapper) Check(ctx context.Context, name string, resource xlist.Resource) (xlist.Response, error)

Check implements xlist.Checker interface.

func (*Wrapper) Class

func (w *Wrapper) Class() string

Class implements xlistd.List interface.

func (*Wrapper) ID

func (w *Wrapper) ID() string

ID implements xlistd.List interface.

func (*Wrapper) Ping

func (w *Wrapper) Ping() error

Ping implements xlistd.Ping interface.

func (*Wrapper) Resources

func (w *Wrapper) Resources(ctx context.Context) ([]xlist.Resource, error)

Resources implements xlist.Checker interface.

Jump to

Keyboard shortcuts

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