mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
✨ Add split sink routing helpers
This commit is contained in:
@@ -14,6 +14,7 @@ BitLogger currently provides:
|
||||
- context fields via `with_context_fields(...)`
|
||||
- optional timestamps via `with_timestamp()`
|
||||
- sink fanout via `fanout_sink(...)`
|
||||
- sink routing via `split_sink(...)` and `split_by_level(...)`
|
||||
- custom integration via `callback_sink(...)`
|
||||
- in-memory buffering via `buffered_sink(...)`
|
||||
- record filtering via `filter_sink(...)`
|
||||
@@ -121,6 +122,25 @@ logger.info("three")
|
||||
ignore(logger.sink.flush())
|
||||
```
|
||||
|
||||
Level-based split sink:
|
||||
|
||||
```moonbit
|
||||
let logger = Logger::new(
|
||||
split_by_level(
|
||||
callback_sink(fn(rec) {
|
||||
println("high priority: \{rec.level.label()} \{rec.message}")
|
||||
}),
|
||||
console_sink(),
|
||||
min_level=Level::Warn,
|
||||
),
|
||||
min_level=Level::Trace,
|
||||
target="split",
|
||||
)
|
||||
|
||||
logger.info("normal output")
|
||||
logger.warn("warning output")
|
||||
```
|
||||
|
||||
Custom text formatter:
|
||||
|
||||
```moonbit
|
||||
|
||||
@@ -29,6 +29,7 @@ version 0.3.0
|
||||
- feat: support formatter tokens `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, and `{fields}` in both runtime and JSON config paths
|
||||
- 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
|
||||
|
||||
### Test
|
||||
|
||||
@@ -40,6 +41,7 @@ version 0.3.0
|
||||
- test: cover dropped-count reporting for bounded config-built queue
|
||||
- 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: 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
|
||||
|
||||
@@ -52,6 +54,7 @@ version 0.3.0
|
||||
- docs: update root README, English README, and Mooncake README with config usage notes
|
||||
- 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: 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