component_model.utils.logger

Bespoke logging functions for use in the other modules.

  • color settings for debug (blue), info (green), warning (orange), error (red) and critical (red background) messages (works currently for Idle and Thonny)

  • counting of warnings and errors

The module should be used in the following way in a module:

import Logger logger = Logger.get_module_logger(__name__, level=0) # In the call of the application module, set the level to the desired logging.xyz,

e.g. logging.DEBUG, which then sets the log level on all sub-modules

To access error counting results use e.g.

print(“Count:”, logger.handlers[0].get_count( [“ERROR”]))

To write a logger warning use

logger.warning(“A message string. Note that only string concatenation with + works”) # logger.info, logger.debug, logger.error and logger.critical work similarly

Functions

get_module_logger(mod_name[, level])

Classes

MsgCounterHandler(logger, *args, **kwargs)

component_model.utils.logger.get_module_logger(mod_name: str, level: int = logging.DEBUG)