Expand description
Portable leveled-logging facade for nano-ros.
§Layering
- This crate carries only the portable types + dispatcher +
macros +
PlatformSink. No backend code. - Per-platform log delivery is the responsibility of each
nros-platform-<rtos>crate, exposingnros_platform_log_write/nros_platform_log_flushvia thenros_platform_*ABI (header atpackages/platform/nros-platform-api/include/nros/platform.h). PlatformSinkis the bridge: a singleLogSinkimpl that forwards to the ABI. Apps that want fan-out (e.g.Platform + /rosout) compose a&'static [&dyn LogSink]manually and pass it toinit.
§Quick start
ⓘ
use nros_log::{Logger, Severity};
use nros_log::{log_info, log_warn};
static LOGGER: Logger = Logger::new("my_node");
fn main() {
nros_log::register_logger(&LOGGER);
nros_log::init(nros_log::sinks::default());
log_info!(&LOGGER, "started; domain = {}", 42);
}Re-exports§
pub use log_params::LogOccurrence;pub use log_params::LogParams;pub use log_params::ThrottleClock;pub use log_params::ToLogParams;pub use pool::MAX_LOGGER_NAME_LEN;pub use pool::dynamic_logger_capacity;pub use pool::dynamic_logger_name_arena;pub use pool::dynamic_loggers_in_use;pub use throttle::ThrottleState;pub use throttle::interval_ms_to_ns;pub use throttle::throttle_decide;
Modules§
- early
- Records that could not be delivered when they were raised: before any sink was installed, or while another thread was inside a sink.
- log_
params - rclrs’s log modifiers —
log_info!(logger.once(), …),.skip_first(),.throttle(d),.only_if(b). - macros
- The emission macros.
- pool
- Bounded storage so
get_or_create_loggercan hand out a logger for a name nobody registered at compile time. - sinks
- Sinks the FACADE itself can offer.
- throttle
- Rate-limited logging, on the
Loggereverything else uses.
Macros§
- log
- Emit one record at a severity chosen at RUNTIME — rclrs’s
log!. - log_
debug - Emit at
crate::Severity::Debug. - log_
error - Emit at
crate::Severity::Error. - log_
fatal - Emit at
crate::Severity::Fatal. - log_
info - Emit at
crate::Severity::Info. - log_
warn - Emit at
crate::Severity::Warn. - nros_
debug_ throttle - Emit at
crate::Severity::Debug, at most once perinterval_msat this call site. - nros_
debug_ throttle_ at - Emit at
crate::Severity::Debug, at most once perinterval_msat this call site, measured against thenow_nsthe CALLER supplies. - nros_
error_ throttle - Emit at
crate::Severity::Error, at most once perinterval_msat this call site. - nros_
error_ throttle_ at - Emit at
crate::Severity::Error, at most once perinterval_msat this call site, measured against thenow_nsthe CALLER supplies. - nros_
fatal_ throttle - Emit at
crate::Severity::Fatal, at most once perinterval_msat this call site. - nros_
fatal_ throttle_ at - Emit at
crate::Severity::Fatal, at most once perinterval_msat this call site, measured against thenow_nsthe CALLER supplies. - nros_
info_ throttle - Emit at
crate::Severity::Info, at most once perinterval_msat this call site. - nros_
info_ throttle_ at - Emit at
crate::Severity::Info, at most once perinterval_msat this call site, measured against thenow_nsthe CALLER supplies. - nros_
trace - Emit at
crate::Severity::Trace. - nros_
trace_ throttle - Emit at
crate::Severity::Trace, at most once perinterval_msat this call site. - nros_
trace_ throttle_ at - Emit at
crate::Severity::Trace, at most once perinterval_msat this call site, measured against thenow_nsthe CALLER supplies. - nros_
warn_ throttle - Emit at
crate::Severity::Warn, at most once perinterval_msat this call site. - nros_
warn_ throttle_ at - Emit at
crate::Severity::Warn, at most once perinterval_msat this call site, measured against thenow_nsthe CALLER supplies.
Structs§
- Format
Buffer - Stack-resident UTF-8 buffer for one log record’s formatted body.
- Logger
- A named logger with a runtime severity threshold.
- Record
- One log entry, handed to each
LogSink.
Enums§
- Child
Error - Why
Logger::create_childmade no child. - Severity
- REP-2012 severity levels: rcutils’s five, in rcutils’s order, plus
Trace.
Constants§
- MAX_
ADDED_ SINKS - How many sinks
add_sinkcan append on top of theinitlist. - MAX_
LOGGERS - Maximum number of named loggers that can be registered via
register_logger. Beyond this,get_loggerreturnsDEFAULT_LOGGER. - REENTRANT_
DEPTH - Deliveries to re-entrant sinks that may be in progress at once before a
record takes the guarded path instead. It bounds a
re-entrant sink that logs through
nros_log(each nested record is one more), so it is kept small: a nested delivery is a frame on the raising stack. Concurrent loggers past it are not lost; they queue as they did before re-entrant sinks existed.
Statics§
- DEFAULT_
LOGGER - Catch-all logger returned when the requested name is not registered (or the intern table is full).
Traits§
- LogSink
- Backend a log record is delivered to.
Functions§
- add_
sink - Append
sinkto the sinks every record is delivered to. - added_
sink_ count - How many sinks
add_sinkhas installed. - dispatch_
holder_ frame - The address of a stack slot in the frame that holds the dispatch guard, or
0when no delivery is in progress. - flush
- Flush every registered sink, appended ones included.
- format_
buffer_ capacity - Returns the configured capacity in bytes.
- get_
logger - Look up a registered logger by name. Returns
DEFAULT_LOGGERif none is registered (callregister_loggerfor a'static Loggerto publish one). - get_
or_ create_ logger - Look up a logger by name, CREATING one if the name is new.
- init
- Install the global sink list.
- nros_
log_ dispatch_ holder_ frame - C spelling of
dispatch_holder_frame, for a platform’s fault handler (the Zephyr port’snros_zephyr_log_dead_holder_check). - nros_
log_ release_ dead_ dispatch_ holder - C spelling of
release_dead_dispatch_holder. - register_
logger - Publish
loggerunder its name so subsequentget_loggercalls with that name return THIS reference. - release_
dead_ dispatch_ holder - Release the dispatch guard on behalf of a holder that will never run again,
and only while
frame(fromdispatch_holder_frame) still holds it. Returns whether it did. - resolve_
logger - Resolve
nameto a logger — the TOTAL form ofget_or_create_logger, and the one spelling every node-shaped accessor uses. - resolve_
node_ logger resolve_loggerfor a NODE’s own logger, marking it as one — the one spelling the node-shaped accessors use (Node::logger,rclc_node_get_logger, the C++ node’s), so the/rosoutsink can publish what upstream publishes. The catch-all is never marked: a node whose name fell back to it would otherwise publish every unnamed logger.- severity_
enabled_ at_ compile_ time - Compile-time ceiling check used by the
nros_*!macros. - severity_
from_ u8 - Reconstruct a
Severityfrom itsu8discriminant. - sinks_
installed - Whether any sink is installed (
initoradd_sink). - timestamp_
available - Whether [
__timestamp_ns] can answer with a real clock.