slogformat

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package slogformat provides a structured JSON log handler for the unikernel daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONHandler

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

JSONHandler outputs structured JSON lines to a writer. It ensures every log entry has: ts, level, msg, and optional component/vm_id fields.

func NewJSONHandler

func NewJSONHandler(w io.Writer) *JSONHandler

NewJSONHandler creates a handler that writes JSON lines to w.

func (*JSONHandler) Enabled

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

Enabled returns true for all levels — level filtering is done by slog itself.

func (*JSONHandler) Handle

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

Handle formats the log record as a JSON line.

func (*JSONHandler) WithAttrs

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

WithAttrs returns a new handler with the given attributes appended.

func (*JSONHandler) WithGroup

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

WithGroup returns a new handler with the given group prefix.

Jump to

Keyboard shortcuts

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