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/core/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::{nros_info, nros_warn};
static LOGGER: Logger = Logger::new("my_node");
fn main() {
nros_log::register_logger(&LOGGER);
nros_log::init(nros_log::sinks::default());
nros_info!(&LOGGER, "started; domain = {}", 42);
}Modules§
Macros§
- nros_
debug - Emit at
crate::Severity::Debug. - nros_
error - Emit at
crate::Severity::Error. - nros_
fatal - Emit at
crate::Severity::Fatal. - nros_
info - Emit at
crate::Severity::Info. - nros_
trace - Emit at
crate::Severity::Trace. - nros_
warn - Emit at
crate::Severity::Warn.
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§
- Severity
- REP-2012 severity levels, mirroring
rcutils_log_severity_t.
Constants§
- 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§
- flush
- Flush every registered sink.
- 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). - init
- Install the global sink list.
- register_
logger - Publish
loggerunder its name so subsequentget_loggercalls with that name return THIS reference. - severity_
enabled_ at_ compile_ time - Compile-time ceiling check used by the
nros_*!macros. - severity_
from_ u8 - Reconstruct a
Severityfrom itsu8discriminant.