Skip to content

Configured-logger-file-runtime-state ​

Read combined file and queue runtime state from a ConfiguredLogger. This helper is the richest file-specific diagnostics API on config-built runtime loggers.

The returned RuntimeFileState value is owned by src/file_model; this configured-logger surface is a facade over Logger[@runtime.RuntimeSink] and delegates runtime file-state reads to the wrapped RuntimeSink.

Interface ​

moonbit
pub fn ConfiguredLogger::file_runtime_state(self : ConfiguredLogger) -> RuntimeFileState? {}

input ​

  • self : ConfiguredLogger - Config-driven runtime logger whose file runtime state should be inspected.

output ​

  • RuntimeFileState? - Combined file and queue diagnostics when the runtime sink is file-backed, otherwise None.

Explanation ​

Detailed rules explaining key parameters and behaviors

  • File-backed sinks return Some(RuntimeFileState) through the wrapped RuntimeSink.
  • Queued file sinks include both file status and queue metrics in the returned state.
  • The returned snapshot object itself is the shared @file_model.RuntimeFileState model, not a configured-logger-owned concrete type.
  • Non-file sinks return None.
  • This helper is richer than file_state() because it can also surface queued backlog and dropped counts.

How to Use ​

Here are some specific examples provided.

When Need Rich File Runtime Diagnostics ​

When support output should include both file and queue state:

moonbit
let state = logger.file_runtime_state()

In this example, callers can inspect availability, failure counters, and queue metrics together.

When Need To Branch On File-backed Runtime Shape ​

When code should behave differently for file-backed config-built loggers:

moonbit
match logger.file_runtime_state() {
  Some(state) => ignore(state)
  None => ()
}

In this example, the optional return value reflects whether the runtime sink is file-backed.

Error Case ​

e.g.:

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

  • If callers only need raw file status without queue context, file_state() may be the simpler API.

Notes ​

  1. Use this helper for the richest file-backed runtime diagnostics on config-built loggers.

  2. It is especially useful for queued file sinks where file health and queue state both matter.

Published from the repository docs folder with VitePress.