obs

package
v1.0.126 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package obs is the shared logging facade for internal/* packages (ADR-0003). It lets leaf packages emit log lines and sanitise user input without importing package main. package main wires the sink once at startup (SetSink) so these lines flow into the same rotating/JSON logger; before that, and in unit tests, the default sink writes to stderr.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugf added in v1.0.16

func Debugf(format string, args ...any)

Debugf formats with a DEBUG prefix and sends the line to the configured sink, but only while debug logging is enabled (SetDebugEnabled).

func Printf

func Printf(format string, args ...any)

Printf formats at INFO level and sends the line to the configured sink.

func Sanitize

func Sanitize(s string) string

Sanitize strips control characters from s to prevent log injection (CWE-117).

This is an INDEPENDENT copy of package main's sanitizeLog (proxy.go), kept separate on purpose: CodeQL's CWE-117 query recognises the inline strings.ReplaceAll sanitiser at each call site, and delegating across a package boundary risks losing that recognition. The two copies are tiny and each behaviour-tested; the property (no control byte survives) is the contract.

func SetDebugEnabled added in v1.0.16

func SetDebugEnabled(on bool)

SetDebugEnabled publishes whether debug-level lines should emit. Called by package main's SetLogLevel on every level change.

func SetSink

func SetSink(fn func(line string))

SetSink publishes the log destination. Call once at startup, before serving traffic. A nil fn is ignored. Subsequent calls replace the sink atomically.

func Warnf

func Warnf(format string, args ...any)

Warnf formats with a WARN prefix and sends the line to the configured sink. Note: unlike package main's logWarnf, this does not apply main's runtime log-level filter (that state lives in main); internal warnings always emit.

Types

This section is empty.

Jump to

Keyboard shortcuts

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