Text-console-sink
Create a formatted console sink from a TextFormatter. This sink is the direct sync constructor for human-readable console output with explicit text formatting rules.
Interface
moonbit
pub fn text_console_sink(formatter : TextFormatter) -> FormattedConsoleSink {input
formatter : TextFormatter- Text formatter used to render each record.
output
FormattedConsoleSink- Console sink that renders through the supplied formatter.
Explanation
Detailed rules explaining key parameters and behaviors
- This helper adapts a
TextFormatterinto a console sink. - It is the direct sync sink counterpart to config-driven
text_console(...)presets. - Use it when code-side formatter composition is preferable to config-driven assembly.
How to Use
Here are some specific examples provided.
When Need Explicit Text Formatting On The Console
When console output should use a custom separator or template:
moonbit
let logger = Logger::new(
text_console_sink(text_formatter(show_timestamp=false, separator=" | ")),
target="pretty",
)In this example, the sink renders through the supplied formatter.
Error Case
e.g.:
If structured JSON output is required, use
json_console_sink()instead.If formatting should be data-driven rather than code-driven, prefer config or presets APIs.
Notes
This is the most direct sync sink constructor for custom text output.
formatted_console_sink(...)is the lower-level variant when the formatter input is already aRecordFormatter.