Expand description
Phase 88 — portable leveled-logging facade for nano-ros.
See docs/roadmap/archived/phase-88-nros-log.md
for the design and acceptance criteria.
§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 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 raised before any sink was installed.
- macros
- Phase 88.2 — the emission macros.
- pool
- phase-417 W4.d — 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
- phase-417 W4.d — 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 — RFC-0102 D1. - 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.
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. - 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.
- register_
logger - Publish
loggerunder its name so subsequentget_loggercalls with that name return THIS reference. - 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 (RFC-0102 D4). 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. - timestamp_
available - Whether [
__timestamp_ns] can answer with a real clock.