pyreporting.logger.Logger#

class Logger(app_name=None, debug=False, log_filename=None)[source]#

Bases: object

Helper class for logging with the pyreporting package

Initialise logging to console and log file.

Parameters:
  • app_name – Name of application to use when creating log directory. If both app_name and log_filename are unspecified, the log file will be disabled and output will be to the console only

  • debug – if True, log debug messages, otherwise they will be ignored

  • log_filename – Full path to log file to create instead of using the default log directory specified by app_name

Methods

default_log

Write a message to the console and log file

log

Write a message to the console and log file

static default_log(level, prefix, identifier, message, supplementary_info, exception)[source]#

Write a message to the console and log file

Parameters:
  • level – Logging level (using Python logging library constants)

  • prefix – Optional description of the message type (e.g. “warning”)

  • identifier – Optional error code/identifier

  • message – Message to write

  • supplementary_info – optional additional info to append to message

  • exception – Optional Exception, if the entry relates to an exception

log(level, prefix, identifier, message, supplementary_info, exception)[source]#

Write a message to the console and log file

Parameters:
  • level – Logging level (using Python logging library constants)

  • prefix – Optional description of the message type (e.g. “warning”)

  • identifier – Optional error code/identifier

  • message – Message to write

  • supplementary_info – optional additional info to append to message

  • exception – Optional Exception, if the entry relates to an exception