Skip to main content

Crate rskit_logging

Crate rskit_logging 

Source
Expand description

Structured logging setup using the tracing ecosystem.

§Layers

  • Vocabulary (always available)config::LoggingConfig / config::LogFormat / config::LogOutput describe logging declaratively and carry no tracing dependency, so configuration crates can compose them without linking the subscriber stack.
  • Setup (setup feature, default-on)init_logging and friends, the LoggingGuard, masking, sampling, per-module levels, and context helpers. Everything built on tracing/tracing-subscriber lives 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 tracing subscribers. Subscriber setup — building and installing tracing subscribers.

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 tracing span every time the function is called.