Expand description
Structured logging setup using the tracing ecosystem.
§Layers
- Vocabulary (always available) —
config::LoggingConfig/config::LogFormat/config::LogOutputdescribe logging declaratively and carry notracingdependency, so configuration crates can compose them without linking the subscriber stack. - Setup (
setupfeature, default-on) —init_loggingand friends, theLoggingGuard, masking, sampling, per-module levels, and context helpers. Everything built ontracing/tracing-subscriberlives here.
§Usage
ⓘ
use rskit_logging::init_logging;
let _guard = init_logging(&config.service.logging)?;
// _guard must stay alive for the duration of the program
tracing::info!(service = "my-svc", "started");§Design
There is intentionally no global logger registry (unlike gokit’s logger.Get(name)).
Callers use tracing directly and scope context via spans + #[tracing::instrument].
init_logging installs a scoped default subscriber;
the returned guard restores the previous subscriber on drop.
Re-exports§
pub use config::LogFormat;pub use config::LogOutput;pub use config::LoggingConfig;pub use error::LoggingResult;pub use masking::DefaultMasker;pub use masking::Masker;pub use masking::MaskingConfig;pub use masking::MaskingMakeWriter;pub use module_levels::ModuleLevelsConfig;pub use module_levels::build_env_filter;pub use otlp::OtlpConfig;pub use otlp::OtlpProvider;pub use sampling::SamplingConfig;pub use setup::LoggingGuard;pub use setup::init_logging;pub use setup::init_logging_env;pub use setup::init_logging_with_masking;pub use setup::init_logging_with_options;pub use setup::LoggingSetup;pub use setup::init_logging_full;
Modules§
- config
- Logging configuration vocabulary (tracing-free, always available). Logging configuration vocabulary.
- context
- Span-level context helpers — component tagging, request enrichment. Span-level context helpers — component tagging, request enrichment.
- error
- Error helpers for logging setup. Error helpers for logging setup.
- fields
- Standard field name constants for the unified log schema. Standard field names for the unified log schema.
- instrument
- Attach a span to a
std::future::Future. - masking
- Sensitive data masking for log output. Sensitive data masking engine for structured log output.
- module_
levels - Per-module log level overrides from config. Per-module log level overrides configured from YAML/config.
- otlp
- OpenTelemetry Logs bridge with OTLP export. OpenTelemetry Logs bridge with OTLP export.
- sampling
- Rate-based log sampling layer. Rate-based log sampling layer.
- setup
- Subscriber setup — building and installing
tracingsubscribers. Subscriber setup — building and installingtracingsubscribers.
Macros§
- debug
- Constructs an event at the debug level.
- error
- Constructs an event at the error level.
- info
- Constructs an event at the info level.
- trace
- Constructs an event at the trace level.
- warn
- Constructs an event at the warn level.
Attribute Macros§
- instrument
- Instruments a function to create and enter a
tracingspan every time the function is called.