More py2.6 love for StreamHandler.

This commit is contained in:
Jakub Warmuz 2015-10-11 16:55:59 +00:00
parent 9702495ff0
commit 9427c474ab
No known key found for this signature in database
GPG key ID: 2A7BAD3A489B52EA

View file

@ -35,10 +35,9 @@ class StreamHandler(logging.StreamHandler):
:rtype: str
"""
output = super(StreamHandler, self).format(record)
out = (StreamHandler.format(self, record) if sys.version_info < (2, 7)
else super(StreamHandler, self).format(record))
if self.colored and record.levelno >= self.red_level:
return ''.join((le_util.ANSI_SGR_RED,
output,
le_util.ANSI_SGR_RESET))
return ''.join((le_util.ANSI_SGR_RED, out, le_util.ANSI_SGR_RESET))
else:
return output
return out