code: def format(self, record):
          
          message_dict = {}
          if isinstance(record.msg, dict):
              message_dict = record.msg
              record.message = None
          else:
              record.message = record.getMessage()
          # only format time if needed
          if "asctime" in self._required_fields:
              record.asctime = self.formatTime(record, self.datefmt)
  
          # Display formatted exception, but allow overriding it in the
          # user-supplied dict.
          if record.exc_info and not message_dict.get('exc_info'):
              message_dict['exc_info'] = self.formatException(record.exc_info)
          if not message_dict.get('exc_info') and record.exc_text:
              message_dict['exc_info'] = record.exc_text
          # Display formatted record of stack frames
          # default format is a string returned from :func:`traceback.print_stack`
          try:
              if record.stack_info and not message_dict.get('stack_info'):
                  message_dict['stack_info'] = self.formatStack(record.stack_info)
          except AttributeError:
              # Python2.7 doesn't have stack_info.
              pass
  
          try:
              log_record = OrderedDict()
          except NameError:
              log_record = {}
  
          self.add_fields(log_record, record, message_dict)
          log_record = self.process_log_record(log_record)
  
          return "%s%s" % (self.prefix, self.jsonify_log_record(log_record))
docs: Formats a log record and serializes to json