cortexkit-log
Logging format, filtering, redaction, rotation, and retention for CortexKit modules, with a synchronous tracing layer.
Add to Cargo.toml:
[]
= "0.3.7"
With a Crates policy, own crates retain their existing logger
names and dependencies are labelled <module_id>.dep.<crate>. Rust crate-name
underscores become hyphens, so hyper_util is logged as
<module_id>.dep.hyper-util. Dependencies default to WARN or the module's own
resolved level, whichever is lower. A CK_LOG directive such as
<module_id>.dep.hyper-util=debug can raise one dependency's level.
Use Crates::ceiling to set a maximum for a crate or module path after
CK_LOG; an OFF ceiling drops matching events. Paths match the event's Rust
module path (or its target if none is recorded) on :: boundaries. The most
specific ceiling wins, and a module-path ceiling can also cap a path in an
own crate without changing its logger name.
Pair this policy with cortexkit-bus-client 0.1.17's outage logs to suppress
async-nats reconnect and handshake logs while keeping its other warnings and
errors:
use ;
let crates = new
.own
.ceiling
.ceiling;
let config = in_dir;
let _ = init_with_crates;
For a caller-composed subscriber, use layer(config)?.0.with_crates(policy);
the same method works on layer_with_stderr_copy(config)?.0. Under the default
store-paths feature, init_from_env_with_crates(policy) applies the same
policy to environment-based initialization.
Do not use an outer filter_fn to enforce CK_LOG; the layer already does
that, and its per-event checks mean an outer filter cannot bypass the policy.
A filter's own predicate can still suppress events. See the crate
documentation for initialization and log-segment retention APIs.