コード例 #1
0
ファイル: LogColors.py プロジェクト: CedricGatay/alerta-jul
class LogColors(object):
    '''Provides the colors that will
    be used when printing Log4J levels'''

    def __init__(self):
        self.color = TermColorCodes()
        # defaults
        # color instance has dinamically assigned attributes 
        # so pylint complaints.
        # pylint: disable-msg=E1101
        self.colors = {"warning": COLORS[COLOR_YELLOW], "warn": COLORS[COLOR_YELLOW],
                       "error": COLORS[COLOR_MAGENTA], "info": COLORS[COLOR_YELLOW],
                       "fine": COLORS[COLOR_GREEN], "finer": COLORS[COLOR_GREEN],
                       "debug": COLORS[COLOR_BLACK], "config": COLORS[COLOR_BLACK],
                       "finest": COLORS[COLOR_BLACK], "fatal": COLORS[COLOR_RED],
                       "severe": COLORS[COLOR_RED], "critical": COLORS[COLOR_RED]}
        self.reset = RESET
        self.backgroundemph = self.color.backgroundemph

    def parse_config(self, properties):
        for (level, color) in properties.get_color_items():
            code = self.color.getCode(color)
            if not code:
                continue
            self.colors[level] = code

    def getLogColor(self, color):
        return self.color.getCode(color)

    def getLevelColor(self, level):
        level = level.lower()
        color = COLORS[COLOR_WHITE]
        if  level in self.colors.keys():
            color = self.colors[level]
        return color
コード例 #2
0
ファイル: LogColors.py プロジェクト: CedricGatay/alerta-jul
 def __init__(self):
     self.color = TermColorCodes()
     # defaults
     # color instance has dinamically assigned attributes 
     # so pylint complaints.
     # pylint: disable-msg=E1101
     self.colors = {"warning": COLORS[COLOR_YELLOW], "warn": COLORS[COLOR_YELLOW],
                    "error": COLORS[COLOR_MAGENTA], "info": COLORS[COLOR_YELLOW],
                    "fine": COLORS[COLOR_GREEN], "finer": COLORS[COLOR_GREEN],
                    "debug": COLORS[COLOR_BLACK], "config": COLORS[COLOR_BLACK],
                    "finest": COLORS[COLOR_BLACK], "fatal": COLORS[COLOR_RED],
                    "severe": COLORS[COLOR_RED], "critical": COLORS[COLOR_RED]}
     self.reset = RESET
     self.backgroundemph = self.color.backgroundemph