def METHOD_NAME(self, record):
    """
    Emit a log record.
    """
    try:
        # Call pre-log hook.
        if self._pre_log_function is not None:
            if not self._logged_anything_during_context:
                self._pre_log_function()
                self._logged_anything_during_context = True
        # Format (currently a no-op).
        msg = self.format(record)
        # Add prefix per line.
        if _is_ipython() or _is_interactive(sys.stderr):
            prefix = self._interactive_prefix
        else:
            prefix = self._noninteractive_prefix
        msg = ''.join(["%s%s\n" % (prefix, line) for line in msg.splitlines()])
        # First, flush stdout, to make sure that stdout and stderr don't get
        # interleaved.  Normally this is automatic, but when stdout is piped,
        # it can be necessary to force a flush to avoid interleaving.
        sys.stdout.flush()
        # Write log message.
        if sys.stderr.__class__.__module__.startswith("prompt_toolkit"):
            with _PromptToolkitStdoutProxyRawCtx(sys.stderr):
                sys.stderr.write(msg)
                sys.stderr.flush()
        else:
            sys.stderr.write(msg)
            # Flush now - we don't want any interleaving of stdout/stderr.
            sys.stderr.flush()
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        self.handleError(record)