mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-29 03:12:21 +00:00
📝 align async build config docs
This commit is contained in:
@@ -3,7 +3,7 @@ name: async-logger-build-config
|
||||
group: api
|
||||
category: async
|
||||
update-time: 20260614
|
||||
description: Create the combined sync-and-async build config used by async logger builder APIs, with the sync logger config applied before the outer async layer.
|
||||
description: Create the combined sync-and-async build config used by async logger builder APIs, whether callers later choose the full sync-first builder path or the specialized text-console builder path.
|
||||
key-word:
|
||||
- async
|
||||
- build
|
||||
@@ -13,7 +13,7 @@ key-word:
|
||||
|
||||
## Async-logger-build-config
|
||||
|
||||
Create an `AsyncLoggerBuildConfig` value that combines the base synchronous `LoggerConfig` with the async runtime `AsyncLoggerConfig`. This is the constructor used when async builder APIs should receive one typed object carrying both layers of setup.
|
||||
Create an `AsyncLoggerBuildConfig` value that combines the base synchronous `LoggerConfig` with the async runtime `AsyncLoggerConfig`. This is the constructor used when async builder APIs should receive one typed object carrying both layers of setup, even though different builders later consume different parts of the embedded sync config.
|
||||
|
||||
### Interface
|
||||
|
||||
@@ -41,6 +41,7 @@ Detailed rules explaining key parameters and behaviors
|
||||
- Omitting `async_config` uses `AsyncLoggerConfig::new()`.
|
||||
- The constructor simply packages both config objects into one public build shape.
|
||||
- When passed to `build_async_logger(...)`, the `logger` portion is built first through the normal synchronous config path before the outer async queue layer is applied.
|
||||
- When passed to `build_async_text_logger(...)`, the same `logger` portion is consumed more narrowly: `text_formatter`, `min_level`, `target`, and `timestamp` are used directly to build a text console sink, while `LoggerConfig.queue` is not applied.
|
||||
- This helper is the main code-side counterpart to `parse_async_logger_build_config_text(...)`.
|
||||
|
||||
### How to Use
|
||||
@@ -59,6 +60,8 @@ let config = AsyncLoggerBuildConfig::new(
|
||||
|
||||
In this example, the builder input keeps both configuration layers in one typed value.
|
||||
|
||||
And later code can still decide whether that shared config should flow into the full sync-first builder or the narrower text-console builder.
|
||||
|
||||
#### When Need Defaulted Async Build Settings
|
||||
|
||||
When code only wants the standard combined config shape with few overrides:
|
||||
@@ -75,8 +78,14 @@ e.g.:
|
||||
|
||||
- If callers only need async runtime policy and not the full builder input shape, `AsyncLoggerConfig::new(...)` is the smaller API.
|
||||
|
||||
- If callers expect every field inside `LoggerConfig` to affect every async builder equally, that assumption is too broad: `build_async_text_logger(...)` intentionally skips the optional sync queue layer.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper when async builder APIs should receive one combined config object.
|
||||
|
||||
2. Pair it with `build_async_logger(...)`, `build_async_text_logger(...)`, or `parse_async_logger_build_config_text(...)` depending on whether the source is code or JSON text.
|
||||
|
||||
3. Prefer `build_async_logger(...)` after constructing this value when configured sync sink behavior, including `LoggerConfig.queue`, should be preserved before async wrapping.
|
||||
|
||||
4. Prefer `build_async_text_logger(...)` after constructing this value when the goal is specifically config-driven text console output with a concrete `FormattedConsoleSink`.
|
||||
|
||||
Reference in New Issue
Block a user