Add file rotation introspection helpers

This commit is contained in:
Nanaloveyuki
2026-05-10 12:42:36 +08:00
parent b68ba073b4
commit 14eaf9e178
8 changed files with 72 additions and 3 deletions
+2 -1
View File
@@ -209,7 +209,8 @@ if native_files_supported() {
- `file_sink(...)` also exposes `reopen()`, `open_failures()`, `write_failures()`, `flush_failures()`, and `rotation_failures()` for basic observability.
- `file_sink(...)` also exposes `append_mode()`. Passing `append=...` to `reopen(...)` updates the current append policy used by later reopen calls.
- `file_sink(...)` also exposes `path()` and `auto_flush_enabled()` for reading basic file-sink policy state.
- `ConfiguredLogger` built through `build_logger(...)` also exposes `file_reopen()`, `file_flush()`, `file_close()`, `file_append_mode()`, `file_path()`, `file_auto_flush()`, and the corresponding file failure counters, so config-driven file logging keeps a usable control surface.
- `file_sink(...)` also exposes `rotation_enabled()` and `rotation_config()` for reading whether rotation is active and which parameters are currently in effect.
- `ConfiguredLogger` built through `build_logger(...)` also exposes `file_reopen()`, `file_flush()`, `file_close()`, `file_append_mode()`, `file_path()`, `file_auto_flush()`, `file_rotation_enabled()`, `file_rotation_config()`, and the corresponding file failure counters, so config-driven file logging keeps a usable control surface.
- `sink.text_formatter.template` currently supports fixed tokens: `{timestamp}`, `{timestamp_ms}`, `{level}`, `{target}`, `{message}`, and `{fields}`.
- Config-driven sink assembly currently supports `console`, `json_console`, `text_console`, and `file`.
- `queue` remains a synchronous bounded wrapper around the final sink, not an async runtime.
+3
View File
@@ -34,6 +34,7 @@ version 0.3.0
- feat: add explicit `file_flush()` and `file_close()` helpers for config-built file sinks, including queued file sink drain-before-close behavior
- feat: make file append mode queryable via `append_mode()` / `file_append_mode()` and persist explicit `reopen(append=...)` mode updates for later reopen calls
- feat: add `path()` / `auto_flush_enabled()` on `FileSink` and `file_path()` / `file_auto_flush()` on `ConfiguredLogger` for basic file-policy introspection
- feat: add `rotation_enabled()` / `rotation_config()` on `FileSink` and `file_rotation_enabled()` / `file_rotation_config()` on `ConfiguredLogger` for rotation-policy introspection
- 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
@@ -52,6 +53,7 @@ version 0.3.0
- test: cover config-built file logger flush/close helpers and queued-file drain semantics
- test: cover append-mode observability and reopen-mode persistence for direct and config-built file sinks
- test: cover path and auto-flush introspection for direct and config-built file sinks
- test: cover rotation introspection for direct and config-built file sinks with and without configured rotation
- 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
@@ -71,6 +73,7 @@ version 0.3.0
- docs: document explicit file flush/close helpers for config-built file loggers
- docs: clarify append-mode observability and reopen append-policy semantics
- docs: document file path and auto-flush introspection helpers
- docs: document rotation introspection helpers for direct and config-built file sinks
- 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