2.8 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| library-async-logger-warn | api | facade | 20260614 | Enqueue a warning-level record through a LibraryAsyncLogger facade by delegating to the wrapped async logger's warn shortcut. |
|
Library-async-logger-warn
Enqueue a warning-level record through the library-facing async logger. This is the convenience wrapper for log(Level::Warn, ...) on LibraryAsyncLogger[S].
Interface
pub async fn[S] LibraryAsyncLogger::warn(
self : LibraryAsyncLogger[S],
message : String,
fields~ : Array[@bitlogger.Field] = [],
) -> Unit {
input
self : LibraryAsyncLogger[S]- Library-facing async logger that should receive the warning record.message : String- Warning message text.fields : Array[@bitlogger.Field]- Optional structured fields added to the record.
output
Unit- No return value. The record is handled according to logger state and policy.
Explanation
Detailed rules explaining key parameters and behaviors
- This helper delegates to
warn(...)on the wrapped async logger, which in turn useslog(Level::Warn, ...). - The record is still subject to min-level gating, stored shared context fields, patching, filtering, and overflow policy.
- Warning records are useful for degraded but non-fatal runtime conditions.
- Use this helper when a named warning call is clearer than a raw
log(...)call. - Async state helpers remain on the underlying
AsyncLogger[S]and requireto_async_logger()first.
How to Use
Here are some specific examples provided.
When Need Async Degradation Signals In Library Code
When the system should report a non-fatal problem:
logger.warn("retry budget running low")
In this example, the event is surfaced at warning severity without using the generic log(...) form.
When Attach Structured Warning Detail
When a warning event should include context:
logger.warn(
"queue near capacity",
fields=[@bitlogger.field("pending", "64")],
)
In this example, the warning carries structured operational detail.
And any shared context fields already stored on the facade are still prepended before these per-call fields.
Error Case
e.g.:
-
If the logger minimum level is above
Warn, the record is skipped before enqueue. -
If the logger is closed or overflow policy prevents acceptance, the write may not become a normal queued record.
-
If callers need a per-call target override, they should use
log(...)instead of this fixed-level shortcut.
Notes
-
Use this helper for notable but non-fatal async runtime conditions.
-
Pair warnings with structured fields when operators need quick context.
-
Use
to_async_logger()first when later code needs queue or failure inspection rather than another write shortcut.