2.3 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| configured-logger-drain | api | runtime | 20260613 | Drain queued work from a configured runtime logger with optional item limits through RuntimeSink. |
|
Configured-logger-drain
Drain queued work from a ConfiguredLogger. This helper is the configured logger wrapper over RuntimeSink::drain(...) when config-driven queue wrapping should be advanced in a controlled, bounded way.
Interface
pub fn ConfiguredLogger::drain(self : ConfiguredLogger, max_items~ : Int = -1) -> Int {}
input
self : ConfiguredLogger- Config-driven runtime logger whose queued work should be drained.max_items : Int- Optional upper bound on how many queued items to drain. Negative values mean no explicit bound.
output
Int- Count returned by the wrappedRuntimeSink::drain(...)call.
Explanation
Detailed rules explaining key parameters and behaviors
- This helper delegates directly to
self.sink.drain(max_items=max_items). - Queue-wrapped sinks forward to the concrete queue sink's
drain(...)behavior and may drain up tomax_itemsrecords. - Plain file sinks fall back to
FileSink::flush()behavior throughRuntimeSinkand return1or0. - Plain console-style sinks return
0because they do not own a drainable queue here.
How to Use
Here are some specific examples provided.
When Need Bounded Queue Progress
When queued output should be advanced in chunks:
let drained = logger.drain(max_items=16)
In this example, callers limit how much queued work is processed in one step.
When Need Full Manual Drain
When the configured queue should be emptied explicitly:
ignore(logger.drain())
In this example, the configured runtime logger drains without imposing an item cap.
Error Case
e.g.:
-
If the configured runtime sink is not queue-backed, draining may return
0or follow the plain-file flush fallback. -
If callers only need generic flush semantics,
flush()may be the simpler API.
Notes
-
Prefer this helper when queue progress should be bounded or observable.
-
Use
pending_count()to inspect remaining backlog after the drain call when the configured sink is queue-backed.