drugex.logs package

Submodules

drugex.logs.config module

class drugex.logs.config.LevelFilter(level)[source]

Bases: Filter

LoggingFilter used to filter one or more specific log levels messages

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class drugex.logs.config.LevelFormatter(formats: Dict[int, str], **kwargs)[source]

Bases: Formatter

LoggingFormatter used to specifiy the formatting per level

format(record: LogRecord) str[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class drugex.logs.config.LogFileConfig(path, logger, debug)[source]

Bases: object

drugex.logs.config.config_logger(log_file_path, debug=None, disable_existing_loggers=True)[source]

Function to configure the logging. All info is saved in a simple format on the log file path. Debug entries are saved to a separate file if debug is True Debug and warning and above are save in a verbose format. Warning and above are also printed to std.out …

Parameters:
  • (str) (log_file_path) –

  • (bool) (no_exist_log) –

  • (bool)

drugex.logs.config.get_git_info()[source]

Get information of the current git commit

If the package is installed with pip, read detailed version extracted by setuptools_scm. Otherwise, use gitpython to get the information from the git repo.

drugex.logs.config.get_runid(log_folder='logs', old=True, id=None)[source]

Fetch runid that is used in all logfiles to identifiy a specific run …

Parameters:
  • (str) (log_folder) –

  • (bool) (old) –

  • (int) (id) –

drugex.logs.config.init_logfile(log, githash=None, args=None)[source]

Put some intial information in the logfile …

Parameters:
  • log (Logging instance) –

  • (str) (githash) –

  • (str)

drugex.logs.utils module

utils

Created by: Martin Sicho On: 17.05.22, 9:55

drugex.logs.utils.backUpFiles(base_dir: str, folder: str, output_prefixes: tuple, cp_suffix=None)[source]
drugex.logs.utils.backUpFilesInFolder(_dir, backup_id, output_prefixes, output_extensions='dummy', cp_suffix=None)[source]
drugex.logs.utils.callwarning(warning_text, exp=None)[source]
drugex.logs.utils.enable_file_logger(log_folder, filename, debug=False, log_name=None, git_hash=None, init_data=None, disable_existing_loggers=True)[source]
drugex.logs.utils.export_conda_environment(filepath: str)[source]

Export the conda environment to a yaml file.

Parameters:

filepath (str) – path to the yaml file

Raises:
drugex.logs.utils.generateBackupDir(root, backup_id)[source]
drugex.logs.utils.generate_backup_runID(path='.')[source]

Generates runID for generation backups of files to be overwritten If no previous backfiles (starting with #) exists, runid is set to 0, else to previous runid+1

Module contents

__init__.py

Created by: Martin Sicho On: 17.05.22, 9:53

drugex.logs.setLogger(log)[source]