📝 clarify built sync target behavior

This commit is contained in:
Nanaloveyuki
2026-06-14 08:16:52 +08:00
parent 8715949242
commit b320b4f1fc
3 changed files with 39 additions and 0 deletions
+13
View File
@@ -37,6 +37,7 @@ Detailed rules explaining key parameters and behaviors
- The embedded config still goes through the normal runtime logger build path, including runtime sink selection, optional queue wrapping, and timestamp application.
- Because the result is only the `ApplicationLogger` alias over `ConfiguredLogger`, this builder does not hide any queue, drain, flush, or file runtime helper methods.
- The returned alias also keeps inherited `Logger` behavior such as `with_target(...)`, `child(...)`, and per-call `target=` overrides on `log(...)`.
- That means `log(..., target=...)` can override the target for one write, while severity helpers such as `info(...)`, `warn(...)`, and `error(...)` continue to use the stored logger target unless a derived logger was created first with `with_target(...)` or `child(...)`.
- Use this alias-oriented entrypoint when application boot code wants an app-specific name without changing the underlying configured runtime logger surface.
### How to Use
@@ -58,6 +59,18 @@ And any queue/file/runtime helpers selected by the config remain directly availa
The returned value also keeps the ordinary logger target semantics because the facade does not wrap or narrow the underlying `ConfiguredLogger`.
#### When Need A Per-call Target Override After App-oriented Build
When typed app config should still build a logger that supports a one-write target override:
```moonbit
let logger = build_application_logger(config)
logger.log(Level::Error, "boom", target="app.audit")
```
In this example, the emitted record uses `app.audit` for that write.
And later `info(...)`, `warn(...)`, or `error(...)` calls still use the logger's stored target unless code derives another logger first with `with_target(...)` or `child(...)`.
### Error Case
e.g.: