simpm.log_cfg — SimPM’s Logging components

Configure logging for SimPM.

The module exposes a shared logger and the LogConfig helper to tweak console/file logging for the simpm package.

Logging levels

  • logging.DEBUG = 10

  • logging.INFO = 20

  • logging.WARNING = 30

  • logging.ERROR = 40

  • logging.CRITICAL = 50

simpm.log_cfg.logger = <Logger simpm (WARNING)>

Instances of the Logger class represent a single logging channel. A “logging channel” indicates an area of an application. Exactly how an “area” is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of “input processing” might include sub-areas “read CSV files”, “read XLS files” and “read Gnumeric files”). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Java or Python package namespace. So in the instance given above, channel names might be “input” for the upper level, and “input.csv”, “input.xls” and “input.gnu” for the sub-levels. There is no arbitrary limit to the depth of nesting.

simpm.log_cfg.log_config() LogConfig

Return the current LogConfig instance.

class simpm.log_cfg.LogConfig(enabled=False, console_level=10, file_level=10, file_path='simpm.log')

LogConfig is a class that allows developers to configure logging settings. It can be used to set parameters such as log output destination, log level, and log formatting. LogConfig provides a way to customize the logging behavior of an application based on specific requirements.

property console_level: int

This property is used to get the console level as an integer.

enabled

This boolean property indicates whether the feature is enabled or disabled.

property file_level: int

This property gets the file level of the instance.

property file_path: str

Return the file path

classmethod last_instance() LogConfig

Return the latest LogConfig instance or create a default one.

property logger: Logger

This property holds a logging.Logger object which can be used to log messages.