logger

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Key   string      `yaml:"key" json:"key"`
	Value interface{} `yaml:"value" json:"value"`
}

type Fields

type Fields []Field

func MapToFields

func MapToFields(m map[string]any) Fields

type Level

type Level int8
const (
	DebugLevel Level = iota - 1
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FatalLevel
)

func ParseLevel

func ParseLevel(text string) Level

func (Level) String

func (lvl Level) String() string

type Logger

type Logger interface {
	SkipCaller(skip int) Logger

	With(fields ...Field) Logger
	WithError(err error) Logger

	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warn(msg string, fields ...Field)
	Error(msg string, fields ...Field)
	Panic(msg string, fields ...Field)
	Fatal(msg string, fields ...Field)

	Sync() error
	Close() error
}
var NopLogger Logger = nopLogger{}

func New

func New(opts ...Option) (Logger, error)

type Option

type Option func(*options)

func WithConsole

func WithConsole(console bool) Option

func WithFields

func WithFields(fields ...Field) Option

func WithFiles

func WithFiles(files ...string) Option

func WithLevel

func WithLevel(lvl Level) Option

func WithLevelText

func WithLevelText(text string) Option

func WithTimeLayout

func WithTimeLayout(layout string) Option

Jump to

Keyboard shortcuts

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