mscp.common_utils.logging_config
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.
Functions
Section titled “Functions”function_filter
Section titled “function_filter”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— Alogururecord dict, of which onlymoduleis read.
Returns
bool—Trueif this record should be emitted to the configured sinks,Falseto suppress it.
set_logger
Section titled “set_logger”set_logger(debug: bool=False, verbosity: int=0) -> loguru.LoggerConfigure 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):ERRORverbosity == 1(-v):WARNINGverbosity == 2(-vv):INFOverbosity > 2ordebug=True:DEBUG
Args
debug(bool) — If true, force the stderr sink toDEBUGlevel regardless ofverbosity. Defaults toFalse.verbosity(int) — Verbosity level from the-vflag. Defaults to0(errors only).
Returns
loguru.Logger— The reconfigured global logger, ready for use.