<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def emit(self, record):
 """Write `record` as a journal event. MESSAGE is taken from the message provided by the user, and PRIORITY, LOGGER, THREAD_NAME, CODE_{FILE,LINE,FUNC} fields are appended automatically. In addition, record.MESSAGE_ID will be used if present. """

        try:
            msg = self.format(record)
            pri = self.map_priority(record.levelno)
            # defaults
            extras = self._extra.copy()

            # higher priority
            if record.exc_text:
                extras['EXCEPTION_TEXT'] = record.exc_text

            if record.exc_info:
                extras['EXCEPTION_INFO'] = record.exc_info

            if record.args:
                extras['CODE_ARGS'] = str(record.args)

            # explicit arguments — highest priority
            extras.update(record.__dict__)

            self.send(msg,
                      PRIORITY=format(pri),
                      LOGGER=record.name,
                      THREAD_NAME=record.threadName,
                      PROCESS_NAME=record.processName,
                      CODE_FILE=record.pathname,
                      CODE_LINE=record.lineno,
                      CODE_FUNC=record.funcName,
                      **extras)
        except Exception:
            self.handleError(record)