Files
BitLogger/docs/api/configured-logger-file-reset-policy.md
T
2026-05-12 14:58:22 +08:00

2.0 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
configured-logger-file-reset-policy api runtime 20260512 Reset the runtime file policy of a configured file-backed logger back to its original defaults.
logger
runtime
file
public

Configured-logger-file-reset-policy

Reset the runtime file policy of a ConfiguredLogger back to its original defaults. This helper restores append, auto-flush, and rotation policy together.

Interface

pub fn ConfiguredLogger::file_reset_policy(self : ConfiguredLogger) -> Bool {}

input

  • self : ConfiguredLogger - Config-driven runtime logger whose file policy should be restored.

output

  • Bool - Whether the reset was applied.

Explanation

Detailed rules explaining key parameters and behaviors

  • File-backed sinks restore their stored default file policy.
  • Queued file sinks forward the reset behavior to the wrapped file sink.
  • Non-file sinks return false.
  • This helper is the inverse of runtime policy drift, not a generic reopen or flush action.

How to Use

Here are some specific examples provided.

When Need To Undo Runtime Policy Changes

When file policy should return to the original configured defaults:

ignore(logger.file_reset_policy())

In this example, append, auto-flush, and rotation settings are restored together.

When Use Drift-aware Recovery

When reset should only happen after runtime changes:

if !logger.file_policy_matches_default() {
  ignore(logger.file_reset_policy())
}

In this example, reset is only applied when runtime policy has diverged.

Error Case

e.g.:

  • If the configured sink is not file-backed, the method returns false.

  • If callers need to restore only one setting, a narrower setter may be more appropriate than a full policy reset.

Notes

  1. Use this helper when the original bundled file policy should be restored intact.

  2. It pairs naturally with file_policy_matches_default() and file_default_policy().