Beispiel #1
0
 def __init__(self, kw_to_color={}, file=None):
     self.kw_to_color = self.KW_TO_COLOR.copy()
     self.kw_to_color.update(kw_to_color)
     self.file = file
     self.fancy = True
     self.isatty = getattr(sys.stderr, 'isatty', lambda: False)
     if self.fancy and self.isatty():
         self.mandelbrot_driver = Driver()
     else:
         self.mandelbrot_driver = None
Beispiel #2
0
"""
A simple color logger.
"""

import sys
from py.io import ansi_print
from rpython.tool.ansi_mandelbrot import Driver

isatty = getattr(sys.stderr, 'isatty', lambda: False)
mandelbrot_driver = Driver()
wrote_dot = False  # global shared state


def _make_method(subname, colors):
    #
    def logger_method(self, text):
        global wrote_dot
        if self.output_disabled:
            return
        text = "[%s%s] %s" % (self.name, subname, text)
        if isatty():
            col = colors
        else:
            col = ()
        if wrote_dot:
            text = '\n' + text
        ansi_print(text, col)
        wrote_dot = False

    #
    return logger_method