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(...). - Internally it serializes the
JsonValueresult with@json_parser.stringify(...)or@json_parser.stringify_pretty(value, 2), so the text form stays aligned with the structured async-config export helper. - The exported text follows the supported async config schema rather than internal queue implementation details.
- Canonical policy labels such as
DropNewestandNeverare emitted even though the parser also accepts aliases likeDropLatestandNone.
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.
Notes
Use this helper when async policy should be copied or logged as text directly.
If negative
max_pendingsemantics matter, remember that the serialized text preserves the config value while runtime queue creation later clamps the queue limit to0.Use
async_logger_config_to_json(...)when the next consumer still needs aJsonValuefor composition before final stringification.