Add template-based text formatter

This commit is contained in:
Nanaloveyuki
2026-05-09 20:41:11 +08:00
parent 3a05efba6a
commit 18479a8b6f
9 changed files with 140 additions and 14 deletions
+5
View File
@@ -25,6 +25,8 @@ version 0.3.0
- feat: support config keys `min_level`, `target`, `timestamp`, `sink.kind`, `sink.path`, `sink.append`, `sink.auto_flush`, `sink.text_formatter`, and `queue`
- feat: support config-driven sink assembly for `console`, `json_console`, `text_console`, and `file`
- feat: use `maria/json_parser` as the first external dependency for practical config loading
- feat: add `TextFormatter.template` and `TextFormatterConfig.template` for template-driven text rendering
- feat: support formatter tokens `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, and `{fields}` in both runtime and JSON config paths
### Test
@@ -34,6 +36,7 @@ version 0.3.0
- test: cover config-built queued text logger flushing and pending count behavior
- test: cover partial drain behavior for config-built queued logger
- test: cover dropped-count reporting for bounded config-built queue
- test: cover template-based formatter rendering and disabled token 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
@@ -44,11 +47,13 @@ version 0.3.0
- docs: add `examples/async_basic` to show async worker startup and queue-backed logging flow
- docs: update `examples/async_basic` to use unified JSON-driven async logger config
- 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 root README and English README with async adapter notes and current scope
- chore: ignore local `.mooncakes/` cache directory in git
### Notes
- current config scope is still intentionally constrained to stable built-in sink shapes
- formatter templates are intentionally limited to simple token replacement and do not yet include conditional blocks or alignment/padding controls
- queue wrapping remains synchronous drain-based delivery, not async runtime scheduling
- async logging remains an isolated adapter layer and currently targets `native/llvm` only