'Emit a record.
If a formatter is specified, it is used to format the record.
The record is then written to the stream with a trailing newline
[ N.B. this may be removed depending on feedback ]. If exception
information is present, it is formatted using
traceback.printException and appended to the stream.'

def emit(self, record):

    try:
        msg = self.format(record)
        fs = '%s'
        if (not hasattr(types, 'UnicodeType')):
            self.stream.write((fs % msg))
        else:
            try:
                self.stream.write((fs % msg))
            except UnicodeError:
                self.stream.write((fs % msg.encode('UTF-8')))
        self.flush()
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        self.handleError(record)
