2.0 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| console | api | config | 20260520 | Create a minimal logger config preset for the built-in console sink. |
|
Console
Create a LoggerConfig preset for the built-in plain console sink. This helper is the shortest way to assemble a config-driven logger that writes directly to the terminal without text formatter customization.
Interface
pub fn console(
min_level~ : Level = Level::Info,
target~ : String = "",
timestamp~ : Bool = false,
) -> LoggerConfig {
input
min_level : Level- Minimum enabled level for the preset.target : String- Default target stored in the returned config.timestamp : Bool- Whether the built logger should emit timestamps.
output
LoggerConfig- Config usingSinkKind::Consolewith no queue wrapper by default.
Explanation
Detailed rules explaining key parameters and behaviors
- This preset always returns
sink.kind=SinkKind::Console. queue=Noneby default, so output remains unqueued unlesswith_queue(...)is applied later.- This helper only selects the sink shape and top-level logger config fields; it does not build a runtime logger by itself.
How to Use
Here are some specific examples provided.
When Need A Minimal Terminal Config
When application startup wants a simple console config:
let config = console(min_level=Level::Debug, target="cli")
let logger = build_logger(config)
In this example, the logger uses the built-in console sink.
And no extra queue or file policy is configured.
Error Case
e.g.:
-
If
targetis empty, the config is still valid. -
If later runtime assembly targets an environment with sink-specific limitations, those runtime rules still apply outside this preset.
Notes
-
Use this preset when you want the shortest path to console output.
-
Apply
with_queue(...)separately if bounded synchronous buffering is needed.