Skip to content

mscp.common_utils.logging_config

Source: src/mscp/common_utils/logging_config.py

loguru configuration for the mSCP CLI.

set_logger wires up a stderr sink whose level depends on -v / -vv / --debug, plus a rotating file sink under logs/mscp.log. function_filter lets developers narrow stderr output to a single module via the MSCP_DEV_FILTER environment variable. The module-level verbose_logging flag is read by spinner_utils.conditional_inject_spinner to decide whether to show a spinner.

function_filter(record)

loguru filter limiting output to a developer-selected module.

Reads the MSCP_DEV_FILTER environment variable; when set, only records whose module name (lowercased) contains the substring pass through. When unset, the empty string is “in” every module name, so nothing is filtered.

Example::

export MSCP_DEV_FILTER=guidance_support

Args

  • record — A loguru record dict, of which only module is read.

Returns

  • boolTrue if this record should be emitted to the configured sinks, False to suppress it.
set_logger(debug: bool=False, verbosity: int=0) -> loguru.Logger

Configure the global loguru logger and return it.

Replaces any existing handlers with a stderr sink (level chosen from verbosity / debug) plus a rotating file sink at logs/mscp.log. Also updates the module-level verbose_logging flag so other modules (e.g. spinner_utils) can adapt their UI.

The stderr level mapping is:

  • verbosity == 0 (default): ERROR
  • verbosity == 1 (-v): WARNING
  • verbosity == 2 (-vv): INFO
  • verbosity > 2 or debug=True: DEBUG

Args

  • debug (bool) — If true, force the stderr sink to DEBUG level regardless of verbosity. Defaults to False.
  • verbosity (int) — Verbosity level from the -v flag. Defaults to 0 (errors only).

Returns

  • loguru.Logger — The reconfigured global logger, ready for use.