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§
- HubLog
Sink - The plugin-side
log::Logimplementation 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 = 1…Trace = 5);Offonly appears as a maximum level.
Statics§
- HUB_
LOG_ SINK - The sink
define_plugin!installs as the plugin’s global logger.
Type Aliases§
- LogSink
Fn - FFI signature the hub provides to each plugin via
PluginVTable::set_log_sink.ctxis opaque and hub-owned;targetis the record’slogtarget (the plugin module path);messageis the formatted record.