mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-30 06:26:38 +00:00
📝 refine library async wrapper methods
This commit is contained in:
@@ -3,7 +3,7 @@ name: library-async-logger-with-target
|
||||
group: api
|
||||
category: facade
|
||||
update-time: 20260613
|
||||
description: Replace the default target carried by a LibraryAsyncLogger facade.
|
||||
description: Replace the default target carried by a LibraryAsyncLogger facade while rewrapping the same underlying async logger state.
|
||||
key-word:
|
||||
- async
|
||||
- library
|
||||
@@ -38,8 +38,9 @@ pub fn[S] LibraryAsyncLogger::with_target(
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- This API delegates to the wrapped async logger's `with_target(...)` behavior and then re-wraps the result.
|
||||
- The returned value keeps the same queue state, sink type, and async config.
|
||||
- The returned value keeps the same sink type, queue state, async config, and failure/lifecycle state because only the default target field changes.
|
||||
- This replaces the default target instead of composing it.
|
||||
- Async state helpers remain hidden behind the narrower facade after rewrapping; use `to_async_logger()` if later code needs them.
|
||||
- The original facade value is not mutated.
|
||||
|
||||
### How to Use
|
||||
@@ -70,6 +71,8 @@ let io = base.with_target("io")
|
||||
|
||||
In this example, one base facade becomes several target-specific async facades.
|
||||
|
||||
And each derived facade still wraps the same kind of queue-backed async logger state, differing only in the default target it carries.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
@@ -82,3 +85,5 @@ e.g.:
|
||||
1. Use this API for replacement, not target-path composition.
|
||||
|
||||
2. It keeps the narrower `LibraryAsyncLogger` boundary intact.
|
||||
|
||||
3. Use `child(...)` when the new target should be combined with the current one instead of replacing it.
|
||||
|
||||
Reference in New Issue
Block a user