📝 refine library async wrapper methods

This commit is contained in:
Nanaloveyuki
2026-06-14 01:08:21 +08:00
parent 3d88ac87a1
commit be8b4f8626
4 changed files with 39 additions and 10 deletions
+7 -1
View File
@@ -3,7 +3,7 @@ name: library-async-logger-child
group: api
category: facade
update-time: 20260613
description: Derive a child LibraryAsyncLogger facade by composing the current target with a child segment.
description: Derive a child LibraryAsyncLogger facade by composing the current target with a child segment while rewrapping the same underlying async logger state.
key-word:
- async
- library
@@ -41,6 +41,8 @@ Detailed rules explaining key parameters and behaviors
- If the parent target is empty, the child target becomes the full target.
- If the child target is empty, the parent target is preserved.
- If both are non-empty, they are joined with `.`.
- Sink type, queue state, async config, and failure/lifecycle state remain the same because only the derived default target changes.
- Async state helpers remain hidden behind the narrower facade after rewrapping; use `to_async_logger()` if later code needs them.
### How to Use
@@ -68,6 +70,8 @@ let client = LibraryAsyncLogger::new(@bitlogger.console_sink(), target="sdk")
In this example, the final facade emits under `sdk.http.client`.
And the target derivation does not rebuild or reset the wrapped async logger state.
### Error Case
e.g.:
@@ -80,3 +84,5 @@ e.g.:
1. This is the preferred library-facing API for hierarchical async target naming.
2. Composition changes the target only and does not rebuild the queue or sink.
3. Use `with_target(...)` instead when the new target should replace the current target rather than extend it.