log

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 9 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 Console added in v0.0.11

func Console(level string, w io.Writer) slog.Handler

Console returns a handler writing compact text lines to w. Callers pick it only when the sink is a terminal (fileIsTTY) — anything else keeps JSON.

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 SetupTTY added in v0.0.11

func SetupTTY(level string, w io.Writer, isTTY bool)

SetupTTY is Setup for a process whose log sink IS the terminal the user is looking at: compact console lines instead of JSON. isTTY should reflect the actual sink (stdout for the daemon's default path); a false keeps JSON.

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