logging

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobField    string = "job"
	SubsysField string = "subsystem"
)

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *slog.Logger

func GetLogger

func GetLogger(ctx context.Context, subsys Subsystem) *slog.Logger

func NewLogFile added in v0.9.2

func NewLogFile(filename string) (f *logFile, err error)

func OutletsFromConfig

func OutletsFromConfig(in config.LoggingOutletEnumList,
) (*logger.Outlets, error)

func ParseOutlet

func ParseOutlet(in config.LoggingOutletEnum) (o slog.Handler, err error)

func With added in v0.9.3

func With(ctx context.Context, args ...any) context.Context

func WithLogger

func WithLogger(ctx context.Context, l *slog.Logger) context.Context

Types

type Buffer added in v0.9.2

type Buffer struct {
	*bytes.Buffer
}

func NewBuffer added in v0.9.2

func NewBuffer() *Buffer

func (*Buffer) Alloc added in v0.9.2

func (self *Buffer) Alloc()

func (*Buffer) Free added in v0.9.2

func (self *Buffer) Free()

type FileOutlet

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

func NewFileOutlet added in v0.9.2

func NewFileOutlet(filename string, formatter *SlogFormatter,
) (*FileOutlet, error)

func (*FileOutlet) Enabled added in v0.9.2

func (self *FileOutlet) Enabled(ctx context.Context, level slog.Level) bool

func (*FileOutlet) Handle added in v0.9.2

func (self *FileOutlet) Handle(_ context.Context, r slog.Record) error

func (*FileOutlet) WithAttrs added in v0.9.2

func (self *FileOutlet) WithAttrs(attrs []slog.Attr) slog.Handler

func (*FileOutlet) WithFormatter

func (self *FileOutlet) WithFormatter(f Formatter) *FileOutlet

func (*FileOutlet) WithGroup added in v0.9.2

func (self *FileOutlet) WithGroup(name string) slog.Handler

func (*FileOutlet) WithWriter

func (self *FileOutlet) WithWriter(w io.Writer) *FileOutlet

type Formatter added in v0.9.2

type Formatter interface {
	Enabled(ctx context.Context, level slog.Level) bool
	WithAttrs(attrs []slog.Attr) Formatter
	WithGroup(name string) Formatter
	Format(r slog.Record) ([]byte, error)
	Write(w io.Writer, r slog.Record) error
}

type SlogFormatter

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

func NewSlogFormatter

func NewSlogFormatter() *SlogFormatter

func (*SlogFormatter) Enabled added in v0.9.2

func (self *SlogFormatter) Enabled(ctx context.Context, level slog.Level) bool

func (*SlogFormatter) Format

func (self *SlogFormatter) Format(r slog.Record) ([]byte, error)

func (*SlogFormatter) WithAttrs added in v0.9.2

func (self *SlogFormatter) WithAttrs(attrs []slog.Attr) Formatter

func (*SlogFormatter) WithGroup added in v0.9.2

func (self *SlogFormatter) WithGroup(name string) Formatter

func (*SlogFormatter) WithHideFields

func (self *SlogFormatter) WithHideFields(fields []string) *SlogFormatter

func (*SlogFormatter) WithJsonHandler

func (self *SlogFormatter) WithJsonHandler() *SlogFormatter

func (*SlogFormatter) WithLevel

func (self *SlogFormatter) WithLevel(level slog.Level) *SlogFormatter

func (*SlogFormatter) WithLogLevel added in v0.9.2

func (self *SlogFormatter) WithLogLevel(enable bool) *SlogFormatter

func (*SlogFormatter) WithLogMetadata added in v0.9.2

func (self *SlogFormatter) WithLogMetadata(v bool) *SlogFormatter

func (*SlogFormatter) WithLogTime

func (self *SlogFormatter) WithLogTime(enable bool) *SlogFormatter

func (*SlogFormatter) WithTextHandler

func (self *SlogFormatter) WithTextHandler() *SlogFormatter

func (*SlogFormatter) Write

func (self *SlogFormatter) Write(w io.Writer, r slog.Record) error

type Subsystem

type Subsystem string
const (
	SubsysCron        Subsystem = "cron"
	SubsysJob         Subsystem = "job"
	SubsysReplication Subsystem = "repl"
	SubsysEndpoint    Subsystem = "endpoint"
	SubsysPruning     Subsystem = "pruning"
	SubsysSnapshot    Subsystem = "snapshot"
	SubsysHooks       Subsystem = "hook"
	SubsysZFSCmd      Subsystem = "zfs.cmd"
)

type SyslogOutlet

type SyslogOutlet struct {
	Formatter     Formatter
	RetryInterval time.Duration
	Facility      syslog.Priority
	// contains filtered or unexported fields
}

func NewSyslogOutlet added in v0.9.2

func NewSyslogOutlet(f *SlogFormatter, facility syslog.Priority,
	retryInterval time.Duration,
) *SyslogOutlet

func (*SyslogOutlet) Enabled added in v0.9.2

func (self *SyslogOutlet) Enabled(ctx context.Context, level slog.Level) bool

func (*SyslogOutlet) Handle added in v0.9.2

func (self *SyslogOutlet) Handle(_ context.Context, r slog.Record) error

func (*SyslogOutlet) WithAttrs added in v0.9.2

func (self *SyslogOutlet) WithAttrs(attrs []slog.Attr) slog.Handler

func (*SyslogOutlet) WithGroup added in v0.9.2

func (self *SyslogOutlet) WithGroup(name string) slog.Handler

type TCPOutlet

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

func NewTCPOutlet

func NewTCPOutlet(formatter Formatter, network, address string,
	tlsConfig *tls.Config, retryInterval time.Duration,
) *TCPOutlet

func (*TCPOutlet) Close

func (h *TCPOutlet) Close()

FIXME: use this method

func (*TCPOutlet) Enabled added in v0.9.2

func (self *TCPOutlet) Enabled(ctx context.Context, level slog.Level) bool

func (*TCPOutlet) Handle added in v0.9.2

func (self *TCPOutlet) Handle(_ context.Context, r slog.Record) error

func (*TCPOutlet) WithAttrs added in v0.9.2

func (self *TCPOutlet) WithAttrs(attrs []slog.Attr) slog.Handler

func (*TCPOutlet) WithGroup added in v0.9.2

func (self *TCPOutlet) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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