slf4go

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: MIT Imports: 9 Imported by: 27

README

slf4go

slf4go, The Structured Logger Facade For Golang

Documentation

Index

Constants

View Source
const (
	TRACE = Level(iota)
	DEBUG
	INFO
	WARN
	ERROR
)

logger levels .

Variables

View Source
var (
	ErrArgs  = errors.New("args number errors", errors.WithVendor(errVendor), errors.WithCode(-1))
	ErrLevel = errors.New("invalid error level", errors.WithVendor(errVendor), errors.WithCode(-2))
)

Errors

Functions

func Config

func Config(config scf4go.Config) error

Config config loggers with scf4go

func RegisterBackend

func RegisterBackend(name string, backend Backend)

RegisterBackend .

func RegisterFilter

func RegisterFilter(filter Filter)

RegisterFilter create filter chain with call order

func Sync

func Sync()

Sync sync flush all logger event

Types

type Backend

type Backend interface {
	Config(config scf4go.Config) error
	Send(entry *EventEntry)
	Sync()
}

Backend .

type EventEntry

type EventEntry struct {
	Timestamp time.Time              `json:"@t"`
	Level     Level                  `json:"@l"`
	Message   string                 `json:"@m"`
	Attrs     map[string]interface{} `json:"@a"`
	Source    string                 `json:"@s"`
	File      string                 `json:"@f"`
	Line      int                    `json:"@line"`
	Function  string                 `json:"@func"`
}

EventEntry .

type Filter

type Filter interface {
	Name() string
	Config(config scf4go.Config)
	MakeChain(backend Backend) Backend
}

Filter .

type Level

type Level int

Level logger level

func (Level) MarshalJSON

func (l Level) MarshalJSON() ([]byte, error)

MarshalJSON .

func (Level) String

func (l Level) String() string

func (*Level) UnmarshalJSON

func (l *Level) UnmarshalJSON(b []byte) error

UnmarshalJSON .

type Logger

type Logger interface {
	Name() string
	T(message string, args ...interface{})
	D(message string, args ...interface{})
	I(message string, args ...interface{})
	W(message string, args ...interface{})
	E(message string, args ...interface{})
}

Logger .

func Get

func Get(name string) Logger

Get create or get logger with name

Directories

Path Synopsis
backend
filter

Jump to

Keyboard shortcuts

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