mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 07:32:22 +00:00
1.5 KiB
1.5 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| console-sink | api | sink | 20260520 | Create the built-in plain console sink for synchronous loggers. |
|
Console-sink
Create the built-in plain console sink. This is the minimal terminal output sink commonly passed to Logger::new(...).
Interface
pub fn console_sink() -> ConsoleSink {
output
ConsoleSink- Sink that writes records to the console using default text formatting.
Explanation
Detailed rules explaining key parameters and behaviors
- This sink writes formatted text to the console.
- It is the simplest built-in sink for direct synchronous logging.
- Use other sink constructors when JSON, custom text formatting, callbacks, routing, or buffering are needed.
How to Use
Here are some specific examples provided.
When Need Minimal Console Output
When a logger only needs default terminal output:
let logger = Logger::new(console_sink(), target="app")
logger.info("ready")
In this example, the logger writes directly to the console sink.
Error Case
e.g.:
-
If richer formatting or routing is required, this sink may be too minimal and another sink constructor should be used.
-
Console output behavior still depends on the current runtime environment.
Notes
-
This is the most common sink constructor for simple sync examples.
-
Use
json_console_sink()ortext_console_sink(...)when output shape matters more explicitly.