mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
✨ Add bind-style context helpers
This commit is contained in:
@@ -21,6 +21,7 @@ BitLogger currently provides:
|
||||
- reusable filter helpers such as `target_has_prefix(...)`, `message_contains(...)`, `level_at_least(...)`, and `field_equals(...)`
|
||||
- record patching via `with_patch(...)` and `patch_sink(...)`
|
||||
- patch helpers such as `prefix_message(...)`, `append_fields(...)`, and `redact_fields(...)`
|
||||
- context binding via `bind(...)` and `fields(...)`
|
||||
- explicit queued delivery via `queued_sink(...)` and `with_queue(...)`
|
||||
- bounded backlog with `QueueOverflowPolicy::DropNewest` and `QueueOverflowPolicy::DropOldest`
|
||||
- configurable text formatting via `text_formatter(...)`, `format_text(...)`, `text_console_sink(...)`, and template-driven `template` output
|
||||
@@ -110,6 +111,15 @@ let logger = Logger::new(console_sink(), target="auth")
|
||||
logger.info("login", fields=[field("user", "alice"), field("token", "secret")])
|
||||
```
|
||||
|
||||
Context binding:
|
||||
|
||||
```moonbit
|
||||
let logger = Logger::new(console_sink(), target="audit")
|
||||
.bind(fields([("service", "bitlogger"), ("scope", "login")]))
|
||||
|
||||
logger.info("accepted", fields=[field("user", "alice")])
|
||||
```
|
||||
|
||||
Explicit queued sink:
|
||||
|
||||
```moonbit
|
||||
|
||||
@@ -30,6 +30,7 @@ version 0.3.0
|
||||
- feat: add `FileRotation`, `file_rotation(...)`, and size-based file rotation with retained backups for `file_sink(...)`
|
||||
- feat: support `sink.rotation.max_bytes` and `sink.rotation.max_backups` in JSON logger config
|
||||
- feat: add `SplitSink`, `split_sink(...)`, and `split_by_level(...)` for routing records into different sinks by predicate or level
|
||||
- feat: add `Logger::bind(...)` as an ergonomic context-binding alias and `fields(...)` helper for tuple-based field construction
|
||||
|
||||
### Test
|
||||
|
||||
@@ -42,6 +43,7 @@ version 0.3.0
|
||||
- test: cover template-based formatter rendering and disabled token behavior
|
||||
- test: cover file rotation config parsing, config roundtrip, and native rotation behavior
|
||||
- test: cover split sink predicate routing and level-based routing behavior
|
||||
- test: cover `bind(...)` context composition and `fields(...)` helper behavior
|
||||
- test: add async logger lifecycle, config roundtrip, and batching/flush policy test seeds
|
||||
- build: verify `bitlogger_async --target native` and `examples/async_basic --target native` compile successfully
|
||||
|
||||
@@ -55,6 +57,7 @@ version 0.3.0
|
||||
- docs: update formatter examples to demonstrate template-based text rendering
|
||||
- docs: update file sink examples to demonstrate rotation and backup retention
|
||||
- docs: add split sink examples for level-based routing
|
||||
- docs: add `bind(...)` examples for reusable context binding
|
||||
- docs: update root README and English README with async adapter notes and current scope
|
||||
- chore: ignore local `.mooncakes/` cache directory in git
|
||||
|
||||
|
||||
Reference in New Issue
Block a user