'Write message to logging object.'

def write(self, data):

    if _in_sighandler:
        return print(safe_str(data), file=sys.__stderr__)
    if getattr(self._thread, u'recurse_protection', False):
        return
    data = data.strip()
    if (data and (not self.closed)):
        self._thread.recurse_protection = True
        try:
            self.logger.log(self.loglevel, safe_str(data))
        finally:
            self._thread.recurse_protection = False
