interfaces

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package interfaces defines the Entry interface for log entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicFormatter

type DynamicFormatter[T kbx.Entry] struct {
	// contains filtered or unexported fields
}

func (*DynamicFormatter[T]) Format

func (f *DynamicFormatter[T]) Format(e T) ([]byte, error)

type FHook

type FHook[T any] func(record T) error

func (FHook[T]) Clone

func (f FHook[T]) Clone() FHook[T]

func (FHook[T]) Fire

func (f FHook[T]) Fire(record T) error

func (FHook[T]) String

func (f FHook[T]) String() string

type Hook

type Hook func(record kbx.Entry) error

type HookFunc

type HookFunc func(record kbx.Entry) error

HookFunc é uma função que implementa a interface Hook.

func (HookFunc) Run

func (f HookFunc) Run(record kbx.Entry) error

Run executa o hook.

type HookFuncG

type HookFuncG[T Hook | *kbx.Entry] func(record T) error

HookFuncG é uma função genérica que implementa a interface HookG.

func (HookFuncG[T]) Run

func (f HookFuncG[T]) Run(record T) error

Run executa o hook genérico.

type HookG

type HookG[T any] func(T) error

HookG é executado antes da formatação/escrita. Pode enriquecer o record, coletar métricas, enviar para outro sistema, etc.

type Hooks

type Hooks []Hook

func (Hooks) Add

func (h Hooks) Add(hook Hook) (Hooks, error)

Add adiciona um hook à coleção.

func (Hooks) Fire

func (h Hooks) Fire(record kbx.Entry) error

Fire executa todos os hooks da coleção.

type HooksG

type HooksG[T any] []HookG[T]

HooksG é uma coleção de hooks.

func (*HooksG[T]) Add

func (h *HooksG[T]) Add(hook HookG[T]) error

Add adiciona um hook à coleção.

func (HooksG[T]) Fire

func (h HooksG[T]) Fire(record T) error

Fire executa todos os hooks da coleção.

type LHook

type LHook[T any] interface {
	Fire(record T) error
	String() string
	Clone() LHook[T]
	Type() T
}

type Logger

type Logger interface {
	SetFormatter(f formatter.Formatter)
	SetOutput(w io.Writer)
	SetMinLevel(min kbx.Level)
	Enabled(level kbx.Level) bool
	GetMinLevel() kbx.Level
	GetLevel() kbx.Level
	SetRotate(rotate bool)
	SetRotateMaxSize(size int64)
	SetRotateMaxBack(back int64)
	SetRotateMaxAge(age int64)
	SetCompress(compress bool)
	SetBufferSize(size int)
	SetFlushInterval(interval time.Duration)
	SetHooks(hooks []Hook)
	SetLHooks(hooks LHook[any])
	SetMetadata(metadata map[string]any)
	SetConfig(config *kbx.LogzConfig)

	Log(lvl kbx.Level, args ...any) error
	LogAny(level kbx.Level, args ...any) error

	AddHook(h Hook)
}

type LoggerFunc

type LoggerFunc interface {
	SetFormatter(f formatter.FormatterFunc)
	SetOutput(w io.Writer)
	SetMinLevel(min kbx.Level)
	SetConfig(config *kbx.LogzConfig)
	Enabled(level kbx.Level) bool

	Log(level kbx.Level, rec kbx.Entry) error

	AddHook(h HookFunc)
}

type LoggerFuncG

type LoggerFuncG[T Hook | *kbx.Entry] interface {
	SetFormatter(f formatter.FormatterFunc)
	SetOutput(w io.Writer)
	SetMinLevel(min kbx.Level)
	SetConfig(config *kbx.LogzConfig)
	Enabled(level kbx.Level) bool

	Log(level kbx.Level, rec T) error

	AddHook(h HookFuncG[T])
}

type LoggerZ

type LoggerZ[T Hook | *kbx.Entry] interface {
	SetFormatter(f formatter.Formatter)
	SetOutput(w io.Writer)
	SetMinLevel(min kbx.Level)
	Enabled(level kbx.Level) bool
	SetConfig(config *kbx.LogzConfig)

	Log(level kbx.Level, rec T) error

	AddHook(h HookG[T])

	SetDebugMode(debug bool)
	Debug(msg ...any)
	Notice(msg ...any)
	Info(msg ...any)
	Success(msg ...any)
	Warn(msg ...any)
	Error(msg ...any) error
	Fatal(msg ...any)
	Trace(msg ...any)
	Critical(msg ...any)
	Answer(msg ...any)
	Alert(msg ...any)
	Bug(msg ...any)
	Panic(msg ...any)
	Println(msg ...any)
	Printf(format string, args ...any)
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Noticef(format string, args ...any)
	Successf(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any) error
	Fatalf(format string, args ...any)
	Tracef(format string, args ...any)
	Criticalf(format string, args ...any)
	Answerf(format string, args ...any)
	Alertf(format string, args ...any)
	Bugf(format string, args ...any)
	Panicf(format string, args ...any)
}

type Writer

type Writer interface {
	Write([]byte) (int, error)
}

Jump to

Keyboard shortcuts

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