lgsg

package
v0.0.0-...-8c7fe1e Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bound

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

Like Sugar, but it retains a handler instance instead and its logging methods do not take a Context

func (Bound) A

func (sgh Bound) A(name string, value any) Bound

Add attribute from any value

func (Bound) Attr

func (sgh Bound) Attr(attrs ...slog.Attr) Bound

Adds slog.Attr attributes

func (Bound) Context

func (sgh Bound) Context(ctx context.Context) context.Context

Gives a new ctx that has a handler with these attributes

func (Bound) Debug

func (sgh Bound) Debug(msg string)

handles a new Debug log record

func (Bound) Error

func (sgh Bound) Error(err error, msg string)

handles a new Error log record, if err is not nil, adds it as an error

func (Bound) Handler

func (sgh Bound) Handler() slog.Handler

Gives new handler with given attributes

func (Bound) Info

func (sgh Bound) Info(msg string)

handles a new Info log record

func (Bound) Log

func (sgh Bound) Log(level slog.Level, msg string)

handles a new log record

func (Bound) LogFromWrapper

func (sgh Bound) LogFromWrapper(additionalWrapDepth int, level slog.Level, msg string)

handles a new log record, this provides all the functionality, able to be used in wrapping log calls

func (Bound) MustNotError

func (sgh Bound) MustNotError(err error)

logs and panics if err is not nil

func (Bound) NoSource

func (sgh Bound) NoSource() Bound

Disables source code location resolution (only works when directly logging)

func (Bound) Warn

func (sgh Bound) Warn(msg string)

handles a new Warn log record

func (Bound) Wrap

func (sgh Bound) Wrap() Bound

Increments the wrap depth, which causes more frames to be skipped when resolving the source lines (only works when directly logging)

type L

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

Sugar handle

func (L) A

func (l L) A(name string, value any) L

Add attribute

func (L) Attr

func (l L) Attr(attr slog.Attr) L

Addes attribute

func (L) Context

func (l L) Context(ctx context.Context) context.Context

Gives a new ctx that has a handler with these attributes

func (L) Debug

func (l L) Debug(ctx context.Context, msg string)

handles a new Debug log record

func (L) Err

func (l L) Err(err error) L

Adds an error attribute to be deeply described

func (L) Error

func (l L) Error(ctx context.Context, msg string)

handles a new Error log record

func (L) Handler

func (l L) Handler(ctx context.Context) slog.Handler

Gives new handler with given attributes

func (L) Info

func (l L) Info(ctx context.Context, msg string)

handles a new Info log record

func (L) Log

func (l L) Log(ctx context.Context, level slog.Level, msg string)

handles a new log record

func (L) LogFromWrapper

func (l L) LogFromWrapper(ctx context.Context, additionalWrapDepth int, level slog.Level, msg string)

handles a new log record

func (L) NoSource

func (l L) NoSource() L

Disables source code location resolution (only works when directly logging)

func (L) Warn

func (l L) Warn(ctx context.Context, msg string)

handles a new Warn log record

func (L) Wrap

func (l L) Wrap() L

Increments the wrap depth, which causes more frames to be skipped when resolving the source lines (only works when directly logging)

type Sugar

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

Base sugar handle

func New

func New() Sugar

Function that returns a sugar handle and ensures that default init was done

func (Sugar) A

func (sgh Sugar) A(name string, value any) Sugar

Add attribute from any value

func (Sugar) Attr

func (sgh Sugar) Attr(attrs ...slog.Attr) Sugar

Adds slog.Attr attributes

func (Sugar) Bound

func (sgh Sugar) Bound(ctx context.Context) Bound

Returns a sugar handle that has a handler from ctx bound to it

func (Sugar) Context

func (sgh Sugar) Context(ctx context.Context) context.Context

Gives a new ctx that has a handler with these attributes

func (Sugar) Debug

func (sgh Sugar) Debug(ctx context.Context, msg string)

handles a new Debug log record

func (Sugar) Error

func (sgh Sugar) Error(ctx context.Context, err error, msg string)

handles a new Error log record, if err is not nil, adds it as an error

func (Sugar) Handler

func (sgh Sugar) Handler(ctx context.Context) slog.Handler

Gives new handler with given attributes

func (Sugar) Info

func (sgh Sugar) Info(ctx context.Context, msg string)

handles a new Info log record

func (Sugar) Log

func (sgh Sugar) Log(ctx context.Context, level slog.Level, msg string)

handles a new log record

func (Sugar) LogFromWrapper

func (sgh Sugar) LogFromWrapper(ctx context.Context, additionalWrapDepth int, level slog.Level, msg string)

handles a new log record, this provides all the functionality, able to be used in wrapping log calls

func (Sugar) MustNotError

func (sgh Sugar) MustNotError(ctx context.Context, err error)

logs and panics if err is not nil

func (Sugar) NoSource

func (sgh Sugar) NoSource() Sugar

Disables source code location resolution (only works when directly logging)

func (Sugar) Warn

func (sgh Sugar) Warn(ctx context.Context, msg string)

handles a new Warn log record

func (Sugar) Wrap

func (sgh Sugar) Wrap() Sugar

Increments the wrap depth, which causes more frames to be skipped when resolving the source lines (only works when directly logging)

Jump to

Keyboard shortcuts

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