mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-24 00:42:18 +00:00
📝 add example-first documentation paths
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# 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
|
||||
|
||||
```moonbit
|
||||
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](../examples/async.md) instead.
|
||||
|
||||
## API Reference
|
||||
|
||||
- [`with_queue(...)`](../api/with-queue.md)
|
||||
- [`QueueConfig`](../api/queue-config.md)
|
||||
- [`QueueOverflowPolicy`](../api/queue-overflow-policy.md)
|
||||
- [`flush()`](../api/configured-logger-flush.md)
|
||||
Reference in New Issue
Block a user