mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-24 00:42:18 +00:00
1.7 KiB
1.7 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| library-logger-to-logger | api | facade | 20260613 | Recover the underlying full sync logger from the library-facing sync facade. |
|
Library-logger-to-logger
Recover Logger[S] from LibraryLogger[S]. This unwraps the library-facing sync facade when code needs methods that are only available on the full logger type.
Interface
pub fn[S] LibraryLogger::to_logger(self : LibraryLogger[S]) -> Logger[S] {}
input
self : LibraryLogger[S]- Library-facing sync logger facade.
output
Logger[S]- The underlying full sync logger.
Explanation
Detailed rules explaining key parameters and behaviors
- This conversion unwraps the existing logger instead of rebuilding it.
- Sink wiring, target, min level, and attached wrappers remain the same.
- Use this when code needs full-surface APIs such as
with_timestamp(...),with_filter(...), orwith_patch(...).
How to Use
Here are some specific examples provided.
When Need Full Logger-only Composition APIs
When a library-facing logger must be widened temporarily for additional composition:
let library_logger = LibraryLogger::new(console_sink(), target="lib")
let full_logger = library_logger.to_logger().with_timestamp()
In this example, the facade is unwrapped so the caller can access full logger composition APIs again.
Error Case
e.g.:
-
If callers only need library-oriented write APIs, unwrapping is unnecessary.
-
Unwrapping does not change the current target or sink behavior by itself.
Notes
-
Use this only when the narrower facade is no longer sufficient.
-
This is the inverse projection of
Logger::to_library_logger().