2.7 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| configured-logger-file-default-policy-or-none | api | runtime | 20260707 | Read the default runtime file policy from a ConfiguredLogger only when it is actually file-backed. |
|
Configured-logger-file-default-policy-or-none
Read the default runtime file policy from a ConfiguredLogger only when it is actually file-backed.
The returned FileSinkPolicy value is owned by src/file_model; this configured-logger surface is a facade over Logger[@runtime.RuntimeSink] and avoids fabricating that model on non-file variants.
This is the truthful companion to file_default_policy(). Prefer it when default-policy inspection should not fabricate a fallback object on non-file sinks.
Interface
pub fn ConfiguredLogger::file_default_policy_or_none(self : ConfiguredLogger) -> FileSinkPolicy? {}
input
self : ConfiguredLogger- Config-driven runtime logger whose default file policy should be inspected.
output
FileSinkPolicy?-Some(policy)when the configured sink is file-backed, otherwiseNone.
Explanation
Detailed rules explaining key parameters and behaviors
- File-backed sinks return
Some(default_policy)through the wrappedRuntimeSink. - Queued file sinks forward the wrapped inner file sink default policy as
Some(default_policy). - The wrapped value is the shared
@file_model.FileSinkPolicymodel, not a configured-logger-owned concrete type. - Non-file sinks return
None. - This helper is useful when callers need to compare runtime drift or restore defaults without fabricating file semantics.
How to Use
Here are some specific examples provided.
When Need Truthful Baseline Policy Visibility
When tooling should inspect defaults only for real file-backed sinks:
let defaults = logger.file_default_policy_or_none()
In this example, None means the configured logger has no file default policy.
When Compare Current And Default Policy Truthfully
When diagnostics should avoid fallback policy objects:
match (logger.file_policy_or_none(), logger.file_default_policy_or_none()) {
(Some(current), Some(defaults)) => ignore((current, defaults))
_ => ()
}
In this example, comparisons happen only when real file semantics exist.
Error Case
e.g.:
-
If the configured sink is not file-backed, the method returns
None. -
If callers only need a drift boolean,
file_policy_matches_default()remains simpler.
Notes
-
Prefer this helper over
file_default_policy()for truthful runtime diagnostics. -
file_default_policy()remains available as the compatibility fallback API.