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 = 0 … LOG_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_layerandinstall_logs_only. - LogFormat
Parse Error - Returned by
LogFormat::parsefor a value that does not match any of the four supported names. - Reopen
Handle - Token returned by
build_logs_layerproving 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§
- Logs
Layer - Boxed fmt layer returned by
build_logs_layer.