cgnal.core.logging package

Submodules

cgnal.core.logging.defaults module

Module for general logging functionalities and abstractions.

class cgnal.core.logging.defaults.WithLogging

Bases: cgnal.core.logging.WithLoggingABC

Base class to be used for providing a logger embedded in the class.

logResult(msg: Union[Callable[[...], str], str], level: typing_extensions.Literal[CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET] = 'INFO') Callable[[...], Any]

Return a decorator to allow logging of inputs/outputs.

Parameters
  • msg – message to log

  • level – logging level

Returns

wrapped method

property logger: logging.Logger

Create logger.

Returns

default logger

cgnal.core.logging.defaults.configFromFiles(config_files: List[Union[str, os.PathLike[str]]], capture_warnings: bool = True, catch_exceptions: Optional[str] = None) None

Configure loggers from configuration obtained merging configuration files.

If any handler inherits from FileHandler create the directory for its output files if it does not exist yet.

Parameters
  • config_files – list of configuration files

  • capture_warnings – whether to capture warnings with logger

  • catch_exceptions – name of the logger used to catch exceptions. If None do not catch exception with loggers.

cgnal.core.logging.defaults.getDefaultLogger(level: typing_extensions.Literal[CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET, 50, 40, 30, 20, 10, 0] = 20) logging.Logger

Create default logger.

Parameters

level – logging level

Returns

logger

cgnal.core.logging.defaults.logger(name: Optional[str] = None) logging.Logger

Return a logger with the specified name, creating it if necessary.

Parameters

name – name to be used for the logger. If None return root logger

Returns

named logger

Module contents

Logging module.

class cgnal.core.logging.LevelsDict(**kwargs)

Bases: dict

Dictionary of logging levels.

CRITICAL: typing_extensions.Literal[50]
DEBUG: typing_extensions.Literal[10]
ERROR: typing_extensions.Literal[40]
INFO: typing_extensions.Literal[20]
NOTSET: typing_extensions.Literal[0]
WARNING: typing_extensions.Literal[30]
class cgnal.core.logging.LoggingConfig(config: cfg_load.Configuration)

Bases: cgnal.core.config.BaseConfig

Logging configuration.

Class instance initializer.

Parameters

config – configuration

property capture_warnings: bool

Flag that determines whether waring are captured.

Returns

capture warnings

property default_config_file: Union[str, os.PathLike[str]]

Return default logging configuration file.

Returns

default config file

property filename: Union[str, os.PathLike[str]]

Name of the file where logs are stored.

Returns

filename

property level: str

Returnn logging level.

Returns

level

class cgnal.core.logging.WithLoggingABC

Bases: abc.ABC

Abstract class providing logging capabilities.

abstract property logger: logging.Logger

Logger instance to be used to output logs within a class.