Configured-logger
ConfiguredLogger is the public sync runtime logger type returned by config-driven build APIs. It is a direct alias to Logger[RuntimeSink], so it keeps ordinary logger write methods while also exposing configured queue and file runtime helpers.
Interface
pub type ConfiguredLogger = Logger[RuntimeSink]output
ConfiguredLogger- Public config-built runtime logger backed byRuntimeSink.
Explanation
Detailed rules explaining key parameters and behaviors
- This is a type alias, not a separate wrapper implementation.
- It preserves normal logger methods such as
info(...),warn(...),error(...), and the otherLoggerAPIs. - Because it is
Logger[RuntimeSink], it also keeps ordinary logger composition and target behavior such aswith_target(...),child(...), and per-calllog(..., target=...)overrides. - In particular,
log(..., target=...)can override the target for one call, while severity helpers such asinfo(...),warn(...), anderror(...)continue using the stored logger target unless code derives another logger first withwith_target(...)orchild(...). - It also exposes configured runtime helpers such as
flush(),drain(),pending_count(),dropped_count(), and file-specific controls when the runtime sink supports them. - Because
ConfiguredLoggeris only an alias overLogger[RuntimeSink], ordinary sync composition helpers such aswith_target(...),child(...),with_timestamp(...),with_filter(...), andwith_patch(...)keep the same visible runtime-sink logger line rather than stripping away the configured helper surface. - In current direct builder coverage, derived configured loggers still preserve queue counters, drain or flush behavior, runtime sink variant choice, and file helper access instead of collapsing back to a narrower non-runtime shape.
- Builders such as
build_logger(...)andparse_and_build_logger(...)return this alias as the main sync config-to-runtime result. ApplicationLoggeris another direct alias-oriented name for this same configured runtime surface, whileLibraryLogger[RuntimeSink]is the narrowing facade variant that intentionally hides these runtime helpers untilto_logger()is used.
How to Use
Here are some specific examples provided.
When Need A Typed Config-built Runtime Logger
When boot code should keep the built logger as a named runtime type:
let logger : ConfiguredLogger = build_logger(LoggerConfig::new(target="svc"))In this example, the configured runtime logger remains a first-class typed value after config assembly.
When Need Normal Logging Plus Runtime Controls
When code should both emit logs and inspect configured runtime behavior:
logger.info("started")
ignore(logger.pending_count())In this example, the alias keeps ordinary logging calls while still exposing runtime diagnostics.
And the inherited logger target rules stay unchanged: log(..., target=...) can override the target per call, while info(...), warn(...), and error(...) continue using the stored target unless code derives another logger first with with_target(...) or child(...).
And later derived values such as logger.child("worker") or logger.with_patch(...) still keep the runtime helper surface because the configured logger line is only being recomposed, not narrowed or rebuilt into a different facade.
When Need A One-call Target Override On The Configured Runtime Logger
When config-built sync code should keep the same logger value but emit one record under a different target:
logger.log(Level::Error, "boom", target="svc.audit")In this example, the emitted record uses svc.audit only for that one call.
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.:
ConfiguredLoggeritself does not have a runtime failure mode.The concrete behavior of queue and file helpers still depends on the configured
RuntimeSinkshape and current backend support.
Notes
Use
build_logger(...)orparse_and_build_logger(...)when you need a value of this type.Inherited
Loggerbehavior stays unchanged on this alias, including target overrides onlog(...)and derived target composition throughwith_target(...)andchild(...).Use
ApplicationLoggerwhen application code wants the same full configured-runtime helper surface under an app-facing name.Use
LibraryLogger[RuntimeSink]when a library boundary should intentionally hide configured-runtime helper methods behind a narrower facade.