comparison python/ppci/errors.py @ 255:7416c923a02a

Added more logging
author Windel Bouwman
date Sun, 04 Aug 2013 15:10:10 +0200
parents 6ed3d3a82a63
children 4496cae24d7f
comparison
equal deleted inserted replaced
254:bd26dc13f270 255:7416c923a02a
1 """ 1 """
2 Error handling routines 2 Error handling routines
3 Diagnostic utils 3 Diagnostic utils
4 """ 4 """
5 5
6 import logging
6 from . import SourceLocation 7 from . import SourceLocation
7 8
8 class CompilerError(Exception): 9 class CompilerError(Exception):
9 def __init__(self, msg, loc=None): 10 def __init__(self, msg, loc=None):
10 self.msg = msg 11 self.msg = msg
48 printLine(r, lines[r-1]) 49 printLine(r, lines[r-1])
49 50
50 class DiagnosticsManager: 51 class DiagnosticsManager:
51 def __init__(self): 52 def __init__(self):
52 self.diags = [] 53 self.diags = []
54 self.logger = logging.getLogger('diagnostics')
53 55
54 def addDiag(self, d): 56 def addDiag(self, d):
57 self.logger.info(str(d))
55 self.diags.append(d) 58 self.diags.append(d)
56 59
57 def error(self, msg, loc): 60 def error(self, msg, loc):
58 self.addDiag(CompilerError(msg, loc)) 61 self.addDiag(CompilerError(msg, loc))
59 62