tslog

package
v0.0.0-...-aa2a2f2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addr

func Addr(key string, addr netip.Addr) slog.Attr

Addr returns a slog.Attr for a netip.Addr.

func AddrPort

func AddrPort(key string, addrPort netip.AddrPort) slog.Attr

AddrPort returns a slog.Attr for a netip.AddrPort.

func AddrPortp

func AddrPortp(key string, addrPortp *netip.AddrPort) slog.Attr

AddrPortp returns a slog.Attr for a *netip.AddrPort.

Use AddrPort if the address is not already on the heap, or the call is guarded by Logger.Enabled.

func Addrp

func Addrp(key string, addrp *netip.Addr) slog.Attr

Addrp returns a slog.Attr for a *netip.Addr.

Use Addr if the address is not already on the heap, or the call is guarded by Logger.Enabled.

func Err

func Err(err error) slog.Attr

Err is a convenience wrapper for tint.Err.

func Int

func Int[V ~int | ~int8 | ~int16 | ~int32 | ~int64](key string, value V) slog.Attr

Int returns a slog.Attr for a signed integer of any size.

func Uint

func Uint[V ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr](key string, value V) slog.Attr

Uint returns a slog.Attr for an unsigned integer of any size.

Types

type Logger

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

Logger is an opinionated logging implementation that writes structured log messages, tinted with color by default, to os.DevNull.

func New

func New(level slog.Level, noColor, noTime bool) (*Logger, func() error, error)

New creates a new *Logger with the given options.

func (*Logger) Debug

func (l *Logger) Debug(msg string, attrs ...slog.Attr)

Debug logs the given message at slog.LevelDebug.

func (*Logger) Enabled

func (l *Logger) Enabled(level slog.Level) bool

Enabled returns whether logging at the given level is enabled.

func (*Logger) Error

func (l *Logger) Error(msg string, attrs ...slog.Attr)

Error logs the given message at slog.LevelError.

func (*Logger) Info

func (l *Logger) Info(msg string, attrs ...slog.Attr)

Info logs the given message at slog.LevelInfo.

func (*Logger) Log

func (l *Logger) Log(level slog.Level, msg string, attrs ...slog.Attr)

Log logs the given message at the given level.

func (*Logger) Warn

func (l *Logger) Warn(msg string, attrs ...slog.Attr)

Warn logs the given message at slog.LevelWarn.

func (*Logger) WithAttrs

func (l *Logger) WithAttrs(attrs ...slog.Attr) *Logger

WithAttrs returns a new *Logger with the given attributes included in every log message.

func (*Logger) WithGroup

func (l *Logger) WithGroup(group string) *Logger

WithGroup returns a new *Logger that scopes all log messages under the given group.

Jump to

Keyboard shortcuts

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