Minor fix (recognizing if it's colorizing handler or not)

This commit is contained in:
Miroslav Stampar 2012-07-12 14:55:54 +02:00
parent cba2a26b68
commit b320dc118d

View File

@ -702,14 +702,15 @@ def setColor(message, bold=False):
if level: if level:
kb.currentMessage = level kb.currentMessage = level
if bold: if hasattr(LOGGER_HANDLER, "level_map"): # colorizing handler
retVal = colored(message, color=None, on_color=None, attrs=("bold",)) if bold:
elif hasattr(LOGGER_HANDLER, "level_map") and hasattr(kb, "currentMessage") and kb.currentMessage: retVal = colored(message, color=None, on_color=None, attrs=("bold",))
_ = LOGGER_HANDLER.level_map.get(logging.getLevelName(kb.currentMessage)) elif hasattr(kb, "currentMessage") and kb.currentMessage:
_ = LOGGER_HANDLER.level_map.get(logging.getLevelName(kb.currentMessage))
if _: if _:
background, foreground, bold = _ background, foreground, bold = _
retVal = colored(message, color=foreground, on_color="on_%s" % background if background else None, attrs=("bold",) if bold else None) retVal = colored(message, color=foreground, on_color="on_%s" % background if background else None, attrs=("bold",) if bold else None)
return retVal return retVal