code: def emit(self, record):
          
          if not self.token:
              raise Exception("Missing Errordite service token.")
  
          if record.levelname == 'EXCEPTION':
              exc_info = record.exc_info
          else:
              exc_info = sys.exc_info()
  
          if exc_info == (None, None, None):
              # we can't find an exception to report on, so just return
              return
  
          ex_type, ex_value, ex_tb = exc_info
          ex_source = traceback.extract_tb(ex_tb)[-1]
  
          payload = {
              "TimestampUtc": datetime.datetime.utcnow().isoformat(),
              "Token": self.token,
              "MachineName": platform.node(),
              "ExceptionInfo": {
                  "Message": record.msg % record.args,
                  "Source": '%s: line %s' % (ex_source[0], ex_source[1]),
                  "ExceptionType": '%s.%s' % (ex_type.__module__, ex_type.__name__),
                  "StackTrace": traceback.format_exc(),
                  "MethodName": ex_source[2]
              }
          }
          if hasattr(record, 'version'):
              payload['Version'] = record.version
  
          # enrich with additional, non-core information. This may be sub-
          # classed
          payload = self.enrich_errordite_payload(payload, record)
  
          try:
              requests.post(
                  ERRORDITE_API_URL,
                  data=json.dumps(payload),
                  headers={'content-type': 'application/json'}
              )
              # since we already in the logger, logging an error, there's
              # there's really nothing we can do with the response that adds
              # any value - so ignore it.
              return 'ok'
  
          except:
              self.handleError(record)
docs: Sends exception info to Errordite.
  
          This handler will ignore the log level, and look for an exception
          within the record (as recored.exc_info) or current stack frame
          (sys.exc_info()). If it finds neither, it will simply return without
          doing anything.