utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandPath

func ExpandPath(path string) (string, error)

ExpandPath expands path "." or "~"

func ReadYaml

func ReadYaml[T any](path string) (t T, err error)

ReadYaml read the YAML file and convert it to T

Types

type ConsoleHandler

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

ConsoleHandler is a Handler that writes Records to an io.Writer as line-delimited JSON objects.

func NewConsoleHandler

func NewConsoleHandler(l slog.Leveler) *ConsoleHandler

NewConsoleHandler creates a ConsoleHandler that writes to w, using the default options.

func (*ConsoleHandler) Enabled

func (c *ConsoleHandler) Enabled(_ context.Context, l slog.Level) bool

Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower.

func (*ConsoleHandler) Handle

func (c *ConsoleHandler) Handle(_ context.Context, r slog.Record) (err error)

Handle formats its argument Record as single line.

If the Record's time is zero, the time is omitted.

If the Record's level is zero, the level is omitted. Otherwise, the key is "level" and the value of [Level.String] is output.

Each call to Handle results in a single serialized call to io.Writer.Write.

func (*ConsoleHandler) WithAttrs

func (c *ConsoleHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs With returns a new ConsoleHandler whose attributes consists of h's attributes followed by attrs.

func (*ConsoleHandler) WithGroup

func (c *ConsoleHandler) WithGroup(name string) slog.Handler

WithGroup returns a new Handler with the given group appended to the receiver's existing groups.

Jump to

Keyboard shortcuts

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