Write message with indentation, context and optional timestamp.

def write(self, s, level=0, color=None):
        """Write message with indentation, context and optional timestamp."""
        if level > self.level:
            return
        if self.timestamps:
            timestamp = time.strftime(u'%H:%M:%S ')
        else:
            timestamp = u''
        with lock:
            if self.context:
                self.stream.write(u'%s%s> ' % (timestamp, self.context))
            elif self.context is None:
                self.stream.write(u'%s%s> ' % (timestamp, get_threadname()))
            self.stream.write(u'%s' % s, color=color)
            try:
                text_type = unicode
            except NameError:
                text_type = str
            self.stream.write(text_type(os.linesep))
            self.stream.flush()