Files
BitLogger/docs/extend/queue.md
T
2026-07-17 16:24:06 +08:00

1.1 KiB

Queueing And Overflow

Use a queue when a short burst of log writes should not immediately reach the output sink. Queueing is explicit because loss behavior is an application decision.

Add A Synchronous Queue

let config = @log.with_queue(
  @log.text_console(target="service"),
  max_pending=128,
  overflow=@log.QueueOverflowPolicy::DropOldest,
)
let logger = @log.build_logger(config)

logger.info("queued record")
ignore(logger.flush())

DropOldest preserves the newest operational information when the queue is full. Use DropNewest when preserving earlier records matters more. Calling flush() at a shutdown boundary makes the pending-record policy visible in application code.

When To Use Async Instead

The synchronous queue is configuration around a normal runtime logger. When a native async application needs a worker lifecycle and batching, follow Async logger lifecycle instead.

API Reference