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.LogRecordinto a Python dict ready to feed.The document carries the following keys:
- _id
- created
- username
- hostname
- qual_name
- ,message
- level
- exception.info (
reprstring ofException) - exception.text (traceback)
Parameters: record – logging.LogRecordReturns: 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 bycore4.logger.MongoAdaptercreated- the logging datetime in UTClevel- the log level as string (DEBUG,INFO,WARNING,ERROR,CRITICAL)hostname- the name of the host sending the messageuser- the name of the user sendingqual_name- the qualified name of the class as created byCoreBase.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 idmessage- the log message
Parameters: record – the log record ( logging.LogRecord)
-