log

package
v0.40.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package log provides support for logging to stdout and stderr.

Log entries will be logged in the following format:

timestamp hostname tag[pid]: SEVERITY Message

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(format string, v ...interface{})

Debug logs a message with severity DEBUG.

func DebugContext

func DebugContext(ctx context.Context, msg string, args ...any)

DebugContext logs a message with severity DEBUG and context.

func Error

func Error(format string, v ...interface{})

Error logs a message with severity ERROR.

func ErrorContext

func ErrorContext(ctx context.Context, msg string, args ...any)

ErrorContext logs a message with severity ERROR and context.

func Fatal

func Fatal(format string, v ...interface{})

Fatal logs a message with severity ERROR followed by a call to os.Exit().

func Info

func Info(format string, v ...interface{})

Info logs a message with severity INFO.

func InfoContext

func InfoContext(ctx context.Context, msg string, args ...any)

InfoContext logs a message with severity INFO and context.

func Logger

func Logger() *slog.Logger

Logger returns the underlying slog.Logger for advanced usage.

func SetFormat added in v0.32.0

func SetFormat(format string)

SetFormat sets the log format. Valid formats are "text" and "json".

func SetLevel

func SetLevel(level string)

SetLevel sets the log level. Valid levels are panic, fatal, error, warn, info and debug.

func SetTag

func SetTag(t string)

SetTag sets the tag.

func WarnContext

func WarnContext(ctx context.Context, msg string, args ...any)

WarnContext logs a message with severity WARN and context.

func Warning

func Warning(format string, v ...interface{})

Warning logs a message with severity WARNING.

func With

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

With returns a new logger with the given attributes.

func WithGroup

func WithGroup(name string) *slog.Logger

WithGroup returns a new logger with the given group.

Types

type ConfdHandler

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

ConfdHandler is a custom slog.Handler that formats logs in confd's traditional format

func (*ConfdHandler) Enabled

func (h *ConfdHandler) Enabled(_ context.Context, level slog.Level) bool

func (*ConfdHandler) Handle

func (h *ConfdHandler) Handle(_ context.Context, r slog.Record) error

func (*ConfdHandler) WithAttrs

func (h *ConfdHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*ConfdHandler) WithGroup

func (h *ConfdHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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