📝 refine async state snapshot docs

This commit is contained in:
Nanaloveyuki
2026-06-14 02:09:29 +08:00
parent 9af489336d
commit 26de2e81d6
5 changed files with 17 additions and 7 deletions
+5 -2
View File
@@ -13,7 +13,7 @@ key-word:
## Stringify-async-logger-state
Serialize `AsyncLoggerState` into JSON text. This is the highest-level diagnostic export helper for async logger snapshots when callers want immediate text output.
Serialize `AsyncLoggerState` into JSON text. This is the highest-level diagnostic export helper for async logger snapshots or manually constructed state values when callers want immediate text output.
### Interface
@@ -26,7 +26,7 @@ pub fn stringify_async_logger_state(
#### input
- `state : AsyncLoggerState` - Snapshot produced by `AsyncLogger::state()`.
- `state : AsyncLoggerState` - Snapshot produced by `AsyncLogger::state()` or any manually constructed `AsyncLoggerState` value.
- `pretty : Bool` - Whether JSON should be pretty-printed.
#### output
@@ -43,6 +43,7 @@ Detailed rules explaining key parameters and behaviors
- Internally it stringifies the same JSON snapshot shape returned by the public export helper, using `@json_parser.stringify(...)` or `@json_parser.stringify_pretty(value, 2)`.
- The compact form matches snapshots such as `{"runtime":{"mode":"native_worker","background_worker":true},"pending_count":0,...}`.
- String output is convenient for logs, CLI output, and startup diagnostics.
- The serializer does not care whether the input came from a live logger read or a synthetic `AsyncLoggerState::new(...)` call.
### How to Use
@@ -81,3 +82,5 @@ e.g.:
3. Use `async_logger_state_to_json(...)` when the next consumer still needs a `JsonValue` for composition before final stringification.
4. Pair it with `AsyncLogger::state()` for current logger diagnostics, or with `AsyncLoggerState::new(...)` when exporting a manual snapshot built by tests or adapters.