logging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logging implements the core's standardized JSON logging: it writes every proxy.Event and every logstream.LogEvent as one JSON object per line to stdout (or any io.Writer). It is the standalone-core substitute for the enterprise webhook notifier and SSE dashboard — same events, transport-free.

Package logging implements the core's standardized JSON logging: it writes every proxy.Event and every logstream.LogEvent as one JSON object per line to stdout (or any io.Writer). This file is the slog-based variant; jsonlog.go is the encoding/json reference. Both satisfy the same proxy.Notifier seam.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger writes proxy.Events and logstream.LogEvents as newline-delimited JSON. It is safe for concurrent use: a mutex serializes writes so one event never interleaves with another.

func New

func New(w io.Writer) *Logger

New returns a Logger writing to w. w is used directly, so a caller that wants trailing-newline-free lines passes a writer that already ends each Write.

func (*Logger) Close

func (l *Logger) Close()

Close implements proxy.Notifier. There is no worker or queue to drain, so it is a no-op.

func (*Logger) Log

func (l *Logger) Log(ev logstream.LogEvent)

Log writes one live log event as a JSON line.

func (*Logger) Notify

func (l *Logger) Notify(ev proxy.Event)

Notify implements proxy.Notifier: it writes the alert event as one JSON line. It never blocks on I/O beyond a single write and never panics.

func (*Logger) Subscribe

func (l *Logger) Subscribe(hub *logstream.Hub) (stop func())

Subscribe attaches the logger to a hub: every published logstream.LogEvent is written as a JSON line, so request.complete, loop_blocked, budget_exceeded, budget_level, and cost_alert events all reach stdout through one path. It returns a stop func that unsubscribes and is safe to call once.

type SlogLogger

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

SlogLogger writes proxy.Events and logstream.LogEvents as newline-delimited JSON via slog's JSONHandler, so each line is a single JSON object pipeable through `jq`. It is safe for concurrent use. It runs off the request path (driven by the hub subscription goroutine or the control plane), so its per-record allocation is not part of the hot-path budget.

func NewSlogLogger

func NewSlogLogger(w io.Writer, level slog.Level) *SlogLogger

NewSlogLogger returns a SlogLogger writing JSON to w at the given level. The handler lowercases slog's built-in "level" (INFO → info) so it matches the event's own lowercase level convention (matching jsonlog.go).

func (*SlogLogger) Close

func (s *SlogLogger) Close()

Close implements proxy.Notifier. There is no worker or queue to drain.

func (*SlogLogger) Log

func (s *SlogLogger) Log(ev logstream.LogEvent)

Log writes one live log event as a JSON line.

func (*SlogLogger) Notify

func (s *SlogLogger) Notify(ev proxy.Event)

Notify implements proxy.Notifier: it writes the alert event as one JSON line. It never blocks beyond a single write and never panics.

func (*SlogLogger) Subscribe

func (s *SlogLogger) Subscribe(hub *logstream.Hub) (stop func())

Subscribe attaches the logger to a hub: every published logstream.LogEvent is written as a JSON line. It returns a stop func safe to call once.

Jump to

Keyboard shortcuts

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