log

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package log provides structured JSON logging over slog.

The core daemon logs JSON lines so they can be shipped to journald, Splunk, or a file without a custom formatter.

Index

Constants

View Source
const (
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
)

Level strings accepted from config.

Variables

This section is empty.

Functions

func From

func From(ctx context.Context) *slog.Logger

From returns the logger stored in ctx, or the default logger.

func ParseLevel

func ParseLevel(s string) slog.Level

ParseLevel maps a config level string to slog.Level. Unknown strings default to info.

func Setup

func Setup(level string, w io.Writer)

Setup configures the default slog handler to write JSON to w.

func WithLogger

func WithLogger(ctx context.Context, logger *slog.Logger) context.Context

WithLogger returns a context carrying logger.

Types

type CtxKey

type CtxKey struct{}

CtxKey is the key under which a logger may be stored in a context.

Jump to

Keyboard shortcuts

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