Async-logger-trace
Enqueue a trace-level record through the async logger. This is the convenience wrapper for log(Level::Trace, ...).
Interface
pub async fn[S] AsyncLogger::trace(
self : AsyncLogger[S],
message : String,
fields~ : Array[@bitlogger.Field] = [],
) -> Unit {}input
self : AsyncLogger[S]- Async logger that should receive the trace record.message : String- Trace message text.fields : Array[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
log(Level::Trace, ..., fields=fields). - The record is still subject to min-level gating, patching, filtering, and overflow policy.
- This helper does not accept a per-call target override. It uses the logger's stored target unless the logger was derived earlier with
with_target(...)orchild(...). - Trace records are often skipped in production because they are the lowest built-in severity.
- Use this helper when explicit trace intent is clearer than a raw
log(...)call.
How to Use
Here are some specific examples provided.
When Need Fine-grained Async Diagnostics
When low-level execution flow should be observable during debugging:
logger.trace("entered reconciliation step")In this example, the call site makes trace intent explicit.
When Attach Structured Trace Data
When a trace event should carry extra fields:
logger.trace(
"cache probe",
fields=[@bitlogger.field("key", "user:42")],
)In this example, the record stays lightweight while still carrying structured detail.
Error Case
e.g.:
If the logger minimum level is above
Trace, 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.
Notes
Prefer this helper when trace intent is more readable than
log(Level::Trace, ...).Use
log(...)instead when one trace call needs a one-off target override.Trace-level async logging can increase queue pressure quickly under verbose workloads.