handler

Implements MongoLoggingHandler to log into MongoDB collection sys.log and make_record() to customise MongoDB documents representing the logging record.

core4.logger.handler.make_record(record)[source]

Internal method to translate a logging.LogRecord into a Python dict ready to feed.

The document carries the following keys:

  • _id
  • created
  • username
  • hostname
  • qual_name
  • ,message
  • level
  • exception.info (repr string of Exception)
  • exception.text (traceback)
Parameters:recordlogging.LogRecord
Returns:dict
class core4.logger.handler.MongoLoggingHandler(connection)[source]

This class implements logging into a MongoDB database/collection.

handle(record)[source]

Handles the logging record by translating it into a mongo database document. The following attributes are saved for each logging.LogRecord.

  • _id - the document id as created by core4.logger.MongoAdapter
  • created - the logging datetime in UTC
  • level - the log level as string (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • hostname - the name of the host sending the message
  • user - the name of the user sending
  • qual_name - the qualified name of the class as created by CoreBase.qual_name()
  • identifier - the core object identifier; this identifier qualifies core workers with the worker name, core jobs with the worker and job id and API requests with its request id
  • message - the log message
Parameters:record – the log record (logging.LogRecord)