ml_switcheroo.utils.console =========================== .. py:module:: ml_switcheroo.utils.console .. autoapi-nested-parse:: Central Logging and Console Utilities. This module unifies the application's output mechanism using the Python standard `logging` library, backed by `rich` for formatting. It serves two primary purposes: 1. **Standard Logging Integration**: Provides a configured `logging.Logger` and adapter functions (`log_success`, `log_warning`) that route to standard logging channels. 2. **Environment Injection**: Implements a Proxy pattern for the Rich Console. This allows the output destination (stdout, file, or in-memory buffer) to be swapped at runtime via `set_console`. This is critical for WebAssembly (WASM) integration, where logs must be captured and returned to the browser context. Attributes ---------- .. autoapisummary:: ml_switcheroo.utils.console.SUCCESS_LEVEL_NUM ml_switcheroo.utils.console.console Functions --------- .. autoapisummary:: ml_switcheroo.utils.console.set_console ml_switcheroo.utils.console.reset_console ml_switcheroo.utils.console.get_console ml_switcheroo.utils.console.log_info ml_switcheroo.utils.console.log_success ml_switcheroo.utils.console.log_warning ml_switcheroo.utils.console.log_error Module Contents --------------- .. py:data:: SUCCESS_LEVEL_NUM :value: 25 .. py:data:: console .. py:function:: set_console(new_console: rich.console.Console) -> None Global helper to inject a specific console instance. This updates both the ``console`` proxy object and the standard ``logging`` handlers to write to the new instance. Use this in Web/WASM contexts to redirect output to a capture buffer. :param new_console: The configured Rich console to use globally. :type new_console: Console .. py:function:: reset_console() -> None Global helper to reset logging and console to standard output. .. py:function:: get_console() -> rich.console.Console Retrieves the currently active console backend. :returns: The active Rich Console. :rtype: Console .. py:function:: log_info(msg: str) -> None Logs an informational message via standard logging. :param msg: The message content. Can include rich markup like [bold]. :type msg: str .. py:function:: log_success(msg: str) -> None Logs a success message via standard logging. :param msg: The message content. :type msg: str .. py:function:: log_warning(msg: str) -> None Logs a warning message via standard logging. :param msg: The message content. :type msg: str .. py:function:: log_error(msg: str) -> None Logs an error message via standard logging. :param msg: The message content. :type msg: str