Skip to main content

Module logging

Module logging 

Source
Expand description

Forwarding of a plugin’s log records to the hub.

A plugin .so carries its own copy of the log crate, so a logger the hub installs in its own process image is invisible to the plugin and its records go nowhere. The hub therefore hands each plugin a LogSinkFn callback (v4 vtable field set_log_sink, called once between create and init); HubLogSink is a log::Log implementation, installed as the plugin’s global logger by the define_plugin! macro, that forwards every enabled record through that callback. Plugin authors only use the log macros and must not install a logger: the hub’s is in place before init runs, so a log::set_logger there fails (and an unwrapping env_logger::init() fails the plugin load).

§Lifetime contract

Same as the metric recorder: the sink callback and its ctx remain valid from set_log_sink until the plugin’s destroy returns; the hub keys ctx by plugin name and never frees it, so a record emitted from a background thread after a reload still lands.

Structs§

HubLogSink
The plugin-side log::Log implementation that forwards to the hub. One per .so; two plugin instances loaded from the same library share it, and records are attributed to whichever instance installed the sink last.

Enums§

LogLevel
Severity of a forwarded record. Discriminants equal log::Level’s (Error = 1Trace = 5); Off only appears as a maximum level.

Statics§

HUB_LOG_SINK
The sink define_plugin! installs as the plugin’s global logger.

Type Aliases§

LogSinkFn
FFI signature the hub provides to each plugin via PluginVTable::set_log_sink. ctx is opaque and hub-owned; target is the record’s log target (the plugin module path); message is the formatted record.