Expand description
The logging framework for Nautilus systems.
This module implements a high-performance logging subsystem that operates in a separate thread
using an MPSC channel for log message delivery. The system uses reference counting to track
active LogGuard instances, ensuring pending file logs are synced when the last guard drops.
§LogGuard reference counting
The logging system maintains a global count of active LogGuard instances using an atomic
counter (LOGGING_GUARDS_ACTIVE). When a LogGuard is created, the counter is incremented,
and when dropped, it’s decremented. When the last LogGuard is dropped (counter reaches zero),
pending file logs are synchronously flushed and synced. The process-global logging thread stays
alive for later guard acquisitions and is only terminated by logging_shutdown.
The system supports a maximum of 255 concurrent LogGuard instances. Attempting to create
more will cause a panic.
Re-exports§
pub use macros::log_debug;pub use macros::log_error;pub use macros::log_info;pub use macros::log_trace;pub use macros::log_warn;
Modules§
- bridge
- Tracing subscriber for capturing logs from external Rust libraries.
- config
- Logging configuration types and parsing.
- headers
- Standard startup, system, and version headers for log output.
- logger
- Core logger lifecycle, filtering, event formatting, and dispatch.
- macros
- Colored logging macros for enhanced log output with automatic color mapping.
- writer
- Stdout, stderr, and rotating file log writers.
Constants§
Functions§
- arm_
shutdown_ on_ error - Arms shutdown-on-error handling for the current run.
- disarm_
shutdown_ on_ error - Disarms shutdown-on-error handling.
- ensure_
logging_ initialized - Ensures logging is initialized on first use.
- init_
logging - Initialize logging.
- log_
task_ aborted - Logs that a task was aborted.
- log_
task_ awaiting - Logs that a task is being awaited.
- log_
task_ error - Logs that there was an error in a task.
- log_
task_ started - Logs that a task has started.
- log_
task_ stopped - Logs that a task has stopped.
- logging_
clock_ set_ realtime_ mode - Sets the global logging clock to real-time mode.
- logging_
clock_ set_ static_ mode - Sets the global logging clock to static mode.
- logging_
clock_ set_ static_ time - Sets the global logging clock static time with the given UNIX timestamp (nanoseconds).
- logging_
is_ colored - Returns whether the core logger is using ANSI colors.
- logging_
is_ initialized - Returns whether the core logger is enabled.
- logging_
set_ bypass - Sets the logging subsystem to bypass mode.
- logging_
shutdown - Shuts down the logging subsystem.
- logging_
sync_ to_ disk - Flushes and syncs file logs to disk.
- map_
log_ level_ to_ filter - Maps a
LogLevelto aLevelFilter. - parse_
component_ levels - Parses component-specific log levels from a JSON value map.
- parse_
level_ filter_ str - Parses a string into a
LevelFilter. - take_
shutdown_ on_ error_ trigger - Returns and clears the pending shutdown-on-error trigger, if one was recorded.
- try_
drain_ shutdown_ on_ error_ trigger - Conditionally drains the pending shutdown-on-error trigger.