swamp.logger.swamplogger module

class SwampLogger(name, silent=False, *args, **kwargs)[source]

Bases: logging.Logger

Class that implements methods to assist with SWAMP logging messages.

Parameters:
  • name (str) – name to identify the logger
  • silent (bool) – if True, messages are not logged
  • args (list) – arguments passed to Logger
  • kwargs (dict) – arguments passed to Logger
Variables:

msg_record (list) – a list with all the messaged recorded into the log (even if silent is set to True)

add_console_handler(level='info')[source]

Add the console handler to the Logger

add_file_handler(fname, level='debug')[source]

Add the file handler to the Logger

debug(msg, *args, **kwargs)[source]

Extend logging.Logger.debug() to check if silent and and format the message

dump_records()[source]

Log all the records in the msg_record

error(msg, *args, **kwargs)[source]

Extend logging.Logger.error() to include the error_header, check if silent and format the message

error_header

Header to highlight error messages

greeting_msg

A greeting message to appear when the logger initiates, informs of the current time and SWAMP version

info(msg, *args, **kwargs)[source]

Extend logging.Logger.info() to check if silent and and format the message

init(console_level='info', logfile_level='debug', logfile=None, use_console=True)[source]

Method to initiate the SwampLogger

Parameters:
  • console_level (str) – indicate the console logging level (default: ‘info’)
  • logfile_level (str) – indicate the logfile logging level (default: ‘debug’)
  • logfile (str) – file name to create a log file (default: None)
  • use_console (bool) – indicate whether or not to use the console while logging (default: True)
logging_levels

A dictionary with the different logger levels that can be set

msg

Property to be used as the format for logged messages

now

Current time

record

Named tuple to be used as a template for the records stored at msg_record

warning(msg, *args, **kwargs)[source]

Extend logging.Logger.warning() to check if silent and format the message