Skip to main content

Module log

Module log 

Source
Expand description

Leveled logger built on tracing + tracing-subscriber.

The Dynomite C engine uses an integer log level on the -v command line (LOG_EMERG = 0LOG_PVERB = 11). The Rust port preserves the numeric scale exactly: callers pass the same 0..11 verbosity and tracing_level_for maps it onto the underlying tracing level filter.

On startup, log_init installs a global tracing_subscriber that writes to either standard error or to a configurable log file. Sending SIGHUP reopens the log file at the stored path; the helper reopen_on_sighup is what the signal handler invokes.

Four output shapes are supported, dispatched by LogFormat: LogFormat::Default (the historical text format), LogFormat::Rfc5424 (modern syslog), LogFormat::Rfc3164 (BSD syslog), and LogFormat::Json (NDJSON). Operators select a shape via the log_format: configuration key or the --log-format CLI flag; when neither is set the default value reproduces the pre-existing behavior byte-for-byte.

§Examples

use dynomite::core::log::{log_init, tracing_level_for, LOG_NOTICE};
use tracing::Level;

assert_eq!(tracing_level_for(LOG_NOTICE), Level::INFO);
// `log_init` is process-global; this is illustrative only.
let _ = log_init(LOG_NOTICE, None);

Structs§

LogConfig
Bundle of tunables consumed by build_logs_layer and install_logs_only.
LogFormatParseError
Returned by LogFormat::parse for a value that does not match any of the four supported names.
ReopenHandle
Token returned by build_logs_layer proving the SIGHUP log-reopen state has been initialised.

Enums§

LogFormat
Selectable on-disk / on-stderr shape for emitted tracing events.

Constants§

LOG_ALERT
Action must be taken immediately.
LOG_CRIT
Critical conditions.
LOG_DEBUG
Debug messages.
LOG_EMERG
System is unusable.
LOG_ERR
Error conditions.
LOG_INFO
Informational.
LOG_LEVEL_MAX
Largest accepted verbosity level.
LOG_NOTICE
Normal but significant condition (default).
LOG_PVERB
Periodic verbose messages.
LOG_VERB
Verbose messages.
LOG_VVERB
Verbose messages, second tier.
LOG_VVVERB
Verbose messages, third tier.
LOG_WARN
Warning conditions.

Functions§

build_env_filter
Build the EnvFilter the install paths feed into the registry.
build_logs_layer
Build the fmt layer for the configured shape and wire the SIGHUP-reopen writer state.
clamp_level
Clamp the supplied verbosity to the inclusive [0, LOG_LEVEL_MAX] window.
current_level
Return the current numeric verbosity stored by log_init.
install_logs_only
Install a fmt-only global tracing subscriber.
local_hostname
Read the local hostname with a deterministic fallback.
log_init
Install the global tracing subscriber.
log_init_with_format
Install the global tracing subscriber with a chosen output shape.
log_level_decrement
Drop the stored verbosity by one, saturating at zero.
log_level_increment
Bump the stored verbosity by one, saturating at LOG_LEVEL_MAX.
log_level_set
Set the stored verbosity directly, clamped to [0, LOG_LEVEL_MAX].
log_loggable
Return whether a given numeric level is loud enough to be logged.
reopen_on_sighup
Reopen the log file at the path remembered by log_init.
tracing_level_for
Map a Dynomite numeric verbosity to a tracing::Level.
write_error_count
Number of write errors observed by the underlying sink.

Type Aliases§

LogsLayer
Boxed fmt layer returned by build_logs_layer.