def log_entry_from_dict(logEntry, log_dict_input): """ Starting with the dictionary representation, recover the original logEntry :param log_dict: dict, as per logEntry.log_dict() :return: logEntry object """ log_dict = copy(log_dict_input) log_dict.pop(MONGO_ID_KEY) log_timestamp_aslong = log_dict.pop(TIMESTAMP_ID) msg_level = log_dict.pop(LEVEL_ID) text = log_dict.pop(TEXT_ID) log_id = log_dict.pop(LOG_RECORD_ID) input_attributes = log_dict log_timestamp = long_to_datetime(log_timestamp_aslong) log_entry = logEntry( text, log_timestamp=log_timestamp, msglevel=msg_level, input_attributes=input_attributes, log_id=log_id, ) return log_entry
def log_handle_caller(self, msglevel, text, input_attributes, log_id): """ Ignores log_level - logs everything, just in case Doesn't raise exceptions """ log_entry = logEntry(text, msglevel=msglevel, input_attributes=input_attributes, log_id=log_id) print(log_entry) self.add_log_record(log_entry) if msglevel in EMAIL_ON_LOG_LEVEL: # Critical, send an email self.email_user(log_entry) return log_entry