4 # Replaces the default formatter by one which understands RVCT output and colorizes it.
6 __author__ = __maintainer__ = "Jérôme Carretero <cJ-waf@zougloub.eu>"
7 __copyright__ = "Jérôme Carretero, 2012"
11 from waflib import Logs
16 for i, e in enumerate(errors):
19 print("Error: %s" % e)
21 atexit.register(show_errors)
23 class RcvtFormatter(Logs.formatter):
24 def __init__(self, colors):
25 Logs.formatter.__init__(self)
27 def format(self, rec):
28 frame = sys._getframe()
30 func = frame.f_code.co_name
31 if func == 'exec_command':
32 cmd = frame.f_locals['cmd']
33 if isinstance(cmd, list) and ('armcc' in cmd[0] or 'armld' in cmd[0]):
35 for line in rec.msg.splitlines():
36 if 'Warning: ' in line:
37 lines.append(self.colors.YELLOW + line)
38 elif 'Error: ' in line:
39 lines.append(self.colors.RED + line)
41 elif 'note: ' in line:
42 lines.append(self.colors.CYAN + line)
45 rec.msg = "\n".join(lines)
47 return Logs.formatter.format(self, rec)
50 Logs.log.handlers[0].setFormatter(RcvtFormatter(Logs.colors))