mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 07:32:22 +00:00
2.0 KiB
2.0 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| stringify-async-logger-config | api | async | 20260512 | Serialize AsyncLoggerConfig into compact or pretty JSON text for export and diagnostics. |
|
Stringify-async-logger-config
Serialize AsyncLoggerConfig into JSON text. This helper is the most direct output path when async runtime policy should be logged, printed, or copied as config text.
Interface
pub fn stringify_async_logger_config(config : AsyncLoggerConfig, pretty~ : Bool = false) -> String {}
input
config : AsyncLoggerConfig- Async config to serialize.pretty : Bool- Whether JSON should be pretty-printed.
output
String- Serialized JSON text for the async config.
Explanation
Detailed rules explaining key parameters and behaviors
pretty=falsereturns compact JSON suitable for transport and snapshots.pretty=truereturns indented JSON for humans.- This helper is built on top of
async_logger_config_to_json(...). - The exported text follows the supported async config schema rather than internal queue implementation details.
How to Use
Here are some specific examples provided.
When Need Human-readable Async Config
When async policy should be printed during startup or testing:
println(stringify_async_logger_config(AsyncLoggerConfig::new(max_pending=32), pretty=true))
In this example, the config is emitted in readable JSON.
When Need Compact Generated Config Text
When async settings should stay small:
let text = stringify_async_logger_config(
AsyncLoggerConfig::new(flush=AsyncFlushPolicy::Shutdown),
)
In this example, compact JSON is returned without extra formatting.
Error Case
e.g.:
-
If callers need a
JsonValuefor composition, they should useasync_logger_config_to_json(...)instead. -
If invalid constructor inputs were normalized earlier, the resulting text contains the normalized config values.