logging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package logging provides unified structured logging utilities for the shim and vminitd components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForwardConsoleLogs

func ForwardConsoleLogs(r io.Reader, raw io.Writer)

ForwardConsoleLogs reads lines from r and re-emits them as structured log entries through the base slog.Handler set via SetBaseHandler.

Lines that are valid JSON objects (emitted by vminitd's JSON slog handler) are parsed and re-emitted preserving the original level, message, and attributes. All other lines are treated as kernel messages and emitted at INFO level with component=kmsg.

The base handler is used directly (rather than the default logger) so that pre-applied attributes such as component=shim are not added to forwarded records, which carry their own component.

If raw is non-nil, every line is also written there verbatim (useful for tests that need the unprocessed console output).

func SetBaseHandler

func SetBaseHandler(h slog.Handler)

SetBaseHandler stores the base handler for use by ForwardConsoleLogs. This should be called before any console forwarding starts, typically during init with the handler before any .With() attributes are applied.

func SetupShimLog

func SetupShimLog()

SetupShimLog configures slog-based logging for the shim process. It opens the platform-specific log output (FIFO on Unix, named pipe on Windows), then creates a slog TextHandler and sets it as the default logger with a "component=shim" attribute.

The base handler (without component) is stored for use by ForwardConsoleLogs so that forwarded records carry their own component rather than inheriting "shim".

For the short-lived start and delete actions, only log.UseSlog is called to route logrus through slog; the log output is not opened.

Types

This section is empty.

Jump to

Keyboard shortcuts

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