logger

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Overview

Package logger the log helpers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

Debug calls Logger.Debug on the default logger.

func Debugf

func Debugf(format string, args ...any)

Debugf calls LevelDebug on the default logger.

func Error

func Error(msg string, err error, args ...any)

Error calls Logger.Error on the default logger.

func Errorf

func Errorf(format string, args ...any)

Errorf calls LevelError on the default logger.

func Info

func Info(msg string, args ...any)

Info calls Logger.Info on the default logger.

func Infof

func Infof(format string, args ...any)

Infof calls LevelInfo on the default logger.

func Logf

func Logf(level slog.Level, format string, args ...any)

Logf calls on the default logger.

func Warn

func Warn(msg string, args ...any)

Warn calls Logger.Warn on the default logger.

func Warnf

func Warnf(format string, args ...any)

Warnf calls LevelWarn on the default logger.

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