Skip to main content

Crate nros_log

Crate nros_log 

Source
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, exposing nros_platform_log_write / nros_platform_log_flush via the nros_platform_* ABI (header at packages/core/nros-platform-api/include/nros/platform.h).
  • PlatformSink is the bridge: a single LogSink impl that forwards to the ABI. Apps that want fan-out (e.g. Platform + /rosout) compose a &'static [&dyn LogSink] manually and pass it to init.

§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
Phase 88.2 — nros_*! macros.
sinks
Phase 88.4 — PlatformSink + helpers.

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§

FormatBuffer
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_logger returns DEFAULT_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_LOGGER if none is registered (call register_logger for a 'static Logger to publish one).
init
Install the global sink list.
register_logger
Publish logger under its name so subsequent get_logger calls 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 Severity from its u8 discriminant.