Skip to main content

Crate stratify

Crate stratify 

Source
Expand description

Layered configuration and structured logging for Rust services.

Two halves behind one crate:

  • config — stack configuration from files, environment variables and Azure App Configuration, merge by declared precedence, read typed values. Always available.
  • logging — a non-blocking tracing facade with console, JSON, file and syslog sinks, per-sink filters, runtime reload, and optional Azure Application Insights export. Behind the logging feature, so a config-only user compiles none of it.

The two meet in one direction only: logging can be described in configuration (logging::settings::Settings reads a [logging] block from a config::Store), and init stands both up in a single call. The config half never depends on the logging half.

use stratify::config;

let store = config::Builder::default()
    .json("config/base.json", 100)
    .yaml("config/override.yaml", 50)
    .env("APP_", "__", 10)
    .build()
    .await?;

let host = store.get_str("database.host");

§Feature flags

  • azureconfig::source::AzureAppConfigSource, reading from Azure App Configuration. Off by default, because it brings in an HTTP stack that a file-and-environment user should not pay for.
  • logging — the logging module and init.
  • compression — gzip retired log files (implies logging).
  • appinsights — export to Azure Application Insights with trace correlation (implies logging).

Modules§

config
Layered configuration: pluggable sources, priority merging, typed access. Layered configuration: pluggable sources, priority merging, typed access.
logging
Structured logging: a non-blocking tracing facade with pluggable sinks.

Macros§

file_source
Macro to generate a file-based configuration source.

Structs§

Bootstrap
What init hands back: the configuration everything else reads, and the handle that keeps the logging workers alive.
Options
How init_with builds the stack. Options::new gives the conventional setup; every field is overridable from there.

Enums§

InitError
Everything that can go wrong before the first log line.

Functions§

init
Read configuration, then stand up logging from it, then install the global subscriber. The conventional form of init_with.
init_with
init with the stack spelled out.