Documentation
¶
Overview ¶
Package observer provides an optional hook that receives agent-internal logs. The logger setup attaches the handler returned by NewHandler to the logger it builds, so any record that passes level filtering is forwarded to the observer registered with SetLogObserver.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLoggerName ¶
func GetLoggerName() string
GetLoggerName returns the recorded logger name (if any).
func NewHandler ¶
NewHandler returns a slog handler that forwards the records it receives to the observer registered with SetLogObserver, if any, and drops them otherwise. Attach it downstream of the async handler — inside the multi-handler it drains — so the observer callback is invoked by the drain loop, one record at a time: it never runs concurrently with itself, and a record is observed before it is written.
func SetLogObserver ¶
func SetLogObserver(h LogObserver)
SetLogObserver registers a process-wide log observer hook. Passing nil disables observation.
func SetLoggerName ¶
func SetLoggerName(name string)
SetLoggerName records the current logger name (e.g. CORE, DOGSTATSD) for low-cardinality tagging. This is optional; if unset, GetLoggerName returns "".
func SimulateLogEmit ¶
SimulateLogEmit invokes the registered LogObserver directly (if any). Intended for tests that need to trigger the observer without going through the logger.
Types ¶
type LogObserver ¶
LogObserver is an optional hook that receives agent-internal logs (already formatted and scrubbed) after level filtering but before they are written to the underlying logger.
Observers MUST be fast and MUST NOT block. Implementations should treat this callback as best-effort.