2.3 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| configured-logger-file-policy-or-none | api | runtime | 20260707 | Read the current runtime file policy from a ConfiguredLogger only when it is actually file-backed. |
|
Configured-logger-file-policy-or-none
Read the current runtime file policy from a ConfiguredLogger only when it is actually file-backed.
This is the truthful companion to file_policy(). Prefer it for diagnostics and recovery logic that must avoid fallback policy objects.
Interface
pub fn ConfiguredLogger::file_policy_or_none(self : ConfiguredLogger) -> FileSinkPolicy? {}
input
self : ConfiguredLogger- Config-driven runtime logger whose current 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(current_policy)through the wrappedRuntimeSink. - Queued file sinks forward the wrapped inner file sink policy as
Some(current_policy). - Non-file sinks return
None. - This helper is broader than
file_append_mode()orfile_auto_flush()because it returns the whole policy object without fallback synthesis.
How to Use
Here are some specific examples provided.
When Need Truthful Policy Diagnostics
When diagnostics should inspect file policy only if file semantics exist:
match logger.file_policy_or_none() {
Some(policy) => ignore(policy)
None => ()
}
In this example, None means there is no real file policy to inspect.
When Need Compatibility-free Recovery Decisions
When recovery logic should not treat a fallback object as real state:
let maybe_policy = logger.file_policy_or_none()
In this example, callers can distinguish missing file semantics from a live policy snapshot.
Error Case
e.g.:
-
If the configured sink is not file-backed, the method returns
None. -
If callers need default-policy comparison, pair it with
file_default_policy_or_none().
Notes
-
Prefer this helper over
file_policy()for truthful runtime diagnostics. -
file_policy()remains available as the compatibility fallback API.