logx

package module
v0.0.0-...-bff5238 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 6 Imported by: 0

README

Logx

[!CAUTION] This library is intended solely for my personal use, so I may not fix bugs, actively support the project, and do ongoing maintenance.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Any = slog.Any

Any returns an Attr for the supplied value. See [AnyValue] for how values are treated.

View Source
var Bool = slog.Bool

Bool returns an Attr for a bool.

View Source
var Duration = slog.Duration

Duration returns an Attr for a time.Duration.

View Source
var Float64 = slog.Float64

Float64 returns an Attr for a floating-point number.

View Source
var Group = slog.Group
View Source
var Int = slog.Int

Int converts an int to an int64 and returns an Attr with that value.

View Source
var Int64 = slog.Int64

Int64 returns an Attr for an int64.

View Source
var NewLogLogger = slog.NewLogLogger

NewLogLogger returns a new log.Logger such that each call to its Output method dispatches a Record to the specified handler. The logger acts as a bridge from the older log API to newer structured logging handlers.

View Source
var NewRecord = slog.NewRecord

NewRecord creates a [Record] from the given arguments. Use [Record.AddAttrs] to add attributes to the Record.

NewRecord is intended for logging APIs that want to support a Handler as a backend.

View Source
var String = slog.String

String returns an Attr for a string value.

View Source
var Time = slog.Time

Time returns an Attr for a time.Time. It discards the monotonic portion.

View Source
var Uint64 = slog.Uint64

Uint64 returns an Attr for a uint64.

Functions

func App

func App(name string) slog.Attr

func Cause

func Cause(err error) slog.Attr

Cause returns an Attr that represents the cause of the error. The Attr contains a string key "cause" with the error's message as its value.

func Module

func Module(name string) slog.Attr

Types

type Attr

type Attr = slog.Attr

func Durationx

func Durationx(key string, value timex.Duration) Attr

func Float32

func Float32(key string, value float32) Attr

Float32 converts an float32 to an float64 and returns an Attr with that value.

func Int16

func Int16(key string, value int16) Attr

Int16 converts an int16 to an int64 and returns an Attr with that value.

func Int32

func Int32(key string, value int32) Attr

Int32 converts an int32 to an int64 and returns an Attr with that value.

func Int8

func Int8(key string, value int8) Attr

Int8 converts an int8 to an int64 and returns an Attr with that value.

func Uint

func Uint(key string, value uint) Attr

Uint converts an uint to an uint64 and returns an Attr with that value.

func Uint16

func Uint16(key string, value uint16) Attr

Uint16 converts an uint16 to an uint64 and returns an Attr with that value.

func Uint32

func Uint32(key string, value uint32) Attr

Uint32 converts an uint32 to an uint64 and returns an Attr with that value.

func Uint8

func Uint8(key string, value uint8) Attr

Uint8 converts an uint8 to an uint64 and returns an Attr with that value.

type Handler

type Handler = slog.Handler

func JoinHandlers

func JoinHandlers(handlers ...Handler) Handler

JoinHandlers creates a Handler that writes to all handlers in the given list.

type Level

type Level = slog.Level
const (
	LevelDebug   Level = -4
	LevelVerbose Level = -2
	LevelInfo    Level = 0
	LevelWarn    Level = 4
	LevelError   Level = 8
	LevelPanic   Level = 10
)

func MustParseLevel

func MustParseLevel(s string) Level

func ParseLevel

func ParseLevel(s string) (Level, error)

type Leveler

type Leveler = slog.Leveler

type Logger

type Logger struct {
	*slog.Logger
}

func New

func New(h Handler) *Logger

func (*Logger) Panic

func (self *Logger) Panic(msg string, args ...any)

func (*Logger) PanicContext

func (self *Logger) PanicContext(ctx context.Context, msg string, args ...any)

func (*Logger) Verbose

func (self *Logger) Verbose(msg string, args ...any)

func (*Logger) VerboseContext

func (self *Logger) VerboseContext(ctx context.Context, msg string, args ...any)

func (*Logger) With

func (self *Logger) With(args ...any) *Logger

func (*Logger) WithGroup

func (self *Logger) WithGroup(name string) *Logger

Directories

Path Synopsis
! Original repository: github.com/MatusOllah/slogcolor
! Original repository: github.com/MatusOllah/slogcolor
! Original repository: github.com/lmittmann/tint
! Original repository: github.com/lmittmann/tint

Jump to

Keyboard shortcuts

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