• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版fd950b81ea5c2bac9a0287fb4d61bdfec213b904 (tree)
时间2013-11-02 21:08:07
作者Albert Mietus < albert AT ons-huis DOT net >
CommiterAlbert Mietus < albert AT ons-huis DOT net >

Log Message

More logging.*

更改概述

差异

diff -r de2c99b913e0 -r fd950b81ea5c compiler/py/donjon/ast/astBase.py
--- a/compiler/py/donjon/ast/astBase.py Thu Oct 31 23:20:51 2013 +0100
+++ b/compiler/py/donjon/ast/astBase.py Sat Nov 02 13:08:07 2013 +0100
@@ -4,6 +4,8 @@
44
55 from ..ccBase import CCBase
66
7+import logging
8+
79 class ASTBaseBase(CCBase):
810 """Base-Base for all AST-Nodes. Most nodes will inherit from ASTBase, but some do not.
911
@@ -29,7 +31,7 @@
2931 super(ASTBase,self).__init__()
3032
3133 if len(DEBUG & set(('all', 'ALL', self.__class__.__name__, 'AST',' AST2', 'init'))):
32- print 'DEBUG %s::super.init(%s;%s)' % (self.__class__.__name__, self._node_no(), ",".join(str(arg) for arg in args))
34+ logging.debug ('%s::super.init(%s;%s)' % (self.__class__.__name__, self._node_no(), ",".join(str(arg) for arg in args)))
3335
3436 def walk(self, topdown=True, _top=None):
3537 """Walk over the complete AST2, in an 'os.walk()' style (Generator)
@@ -45,12 +47,11 @@
4547
4648
4749 if len(DEBUG & set(('all', 'ALL', 'walk'))):
48- print "DEBUG {type:>50}.walk()\t {node}".format(type=type(self),node=self)
50+ logging.debug("{type:>50}.walk()\t {node}".format(type=type(self),node=self))
4951 descendants = self._descendants()
5052 for d in descendants:
5153 if not isinstance(d, ASTBase):
52- import sys
53- print >>sys.stderr, "WARNING walk(): descendant '{d}' (type={type}) of node '{node}' ({no}) is not ASTBase-derived. Skipping it".format(d=d,type=type(d), node=repr(self), no=self._node_no())
54+ logging.error("WARNING walk(): descendant '{d}' (type={type}) of node '{node}' ({no}) is not ASTBase-derived. Skipping it".format(d=d,type=type(d), node=repr(self), no=self._node_no()))
5455 descendants.remove(d)
5556 if topdown:
5657 yield self,_top,descendants
@@ -95,10 +96,8 @@
9596 try:
9697 child_lines = "\n".join([c.dump(indent_with=indent_with, indent_level=indent_level+1) for c in self.childs])
9798 return ("childs=[\n" + child_lines + "]" ) if len(self.childs)>0 else ""
98- except AttributeError:
99- import sys
100- print >>sys.stderr,"LOG: can't dumpChilds of %s" % self
101- # Probally .childs isn't set yet
99+ except AttributeError: # Probally .childs isn't set yet
100+ logging.error("Can't dumpChilds of %s" % self)
102101 return ""
103102
104103 def _descendants(self):
diff -r de2c99b913e0 -r fd950b81ea5c compiler/py/donjon/ast/protocol.py
--- a/compiler/py/donjon/ast/protocol.py Thu Oct 31 23:20:51 2013 +0100
+++ b/compiler/py/donjon/ast/protocol.py Sat Nov 02 13:08:07 2013 +0100
@@ -8,6 +8,7 @@
88 from .astBase import ASTBase
99 from ..ccBase import CCmixInNamed
1010
11+import logging
1112
1213 class ProtocolKindBase(ASTBase): pass # Event and such ...
1314
@@ -28,11 +29,11 @@
2829 def setKind(self, kind):
2930 if self.kind == UNKNOWN:
3031 self.kind = kind
31- else: print "ERROR: Protocol-kind already set to %s. Ignored" % kinds.name(self.kind)
32+ else: logging.error("Protocol-kind already set to %s. Ignored" % kinds.name(self.kind))
3233
3334 def append(self, child):
3435 if self.kind is child.kind: super(Protocol,self).append(child)
35- else: print "Error, can append %s to %s-Protocol. Ignored!" % (kinds.name(child.kind), kinds.name(self.kind))
36+ else: logging.error("Can append %s to %s-Protocol. Ignored!" % (kinds.name(child.kind), kinds.name(self.kind)))
3637
3738
3839 class Event(ProtocolKindBase, CCmixInNamed):
diff -r de2c99b913e0 -r fd950b81ea5c compiler/py/donjon/ast/types.py
--- a/compiler/py/donjon/ast/types.py Thu Oct 31 23:20:51 2013 +0100
+++ b/compiler/py/donjon/ast/types.py Sat Nov 02 13:08:07 2013 +0100
@@ -97,8 +97,6 @@
9797 else: # typespec is a sequence: so it becomes a MACRO type
9898 super(Type, self).__init__(None, id=ALL_TYPES._MACRO)
9999 self.sub_types = tuple([Type(e) for e in typespec])
100-# import sys
101-# print >> sys.stderr, 'XXX', self.__dict__
102100
103101 def __repr__ (self, prefix=True):
104102 retval =""
diff -r de2c99b913e0 -r fd950b81ea5c compiler/py/donjon/aux/graphviz.py
--- a/compiler/py/donjon/aux/graphviz.py Thu Oct 31 23:20:51 2013 +0100
+++ b/compiler/py/donjon/aux/graphviz.py Sat Nov 02 13:08:07 2013 +0100
@@ -5,6 +5,8 @@
55 from donjon.ccBase import CCBase
66 from donjon.sdg import vsymbols
77
8+import logging
9+
810 def _GVid(node):
911 return node.className().replace('.','_DOT_') + '_' + str(node._node_no())
1012
@@ -140,7 +142,7 @@
140142 MemberBase: ',shape=cds',
141143 }
142144 except ImportError as e:
143- print "Can't create MARKERS:", e
145+ logging.error("Can't create MARKERS: %s"% e)
144146 MARKERS={}
145147
146148 m = ''
diff -r de2c99b913e0 -r fd950b81ea5c compiler/py/donjon/aux/parseLib.py
--- a/compiler/py/donjon/aux/parseLib.py Thu Oct 31 23:20:51 2013 +0100
+++ b/compiler/py/donjon/aux/parseLib.py Sat Nov 02 13:08:07 2013 +0100
@@ -1,6 +1,5 @@
11 # Copyright (C) ALbert Mietus, SoftwareBeterMaken.nl; 2013. Part of Castle-project
22
3-import sys
43 import logging
54
65 USE_CPICKLE=True # cPickle-2.7 has a assert bug!
@@ -18,7 +17,7 @@
1817 parser = CastleParser(tokens)
1918 ast1 = parser.parse(src)
2019 except IOError,e:
21- print >> sys.stderr, "IO Error:", e, "for file:", src
20+ logging.error("IO Error: %s for file:%s", e, src)
2221 return
2322
2423 # Walk the ast1: to produce the ast2. which also checks the ast1
@@ -37,14 +36,14 @@
3736 gvfile=file(filename, 'w')
3837 gvfile.write("%s" % gen.toDOT(ast1.tree))
3938 except IOError,e:
40- print >> sys.stderr, "IO Error:", e,
39+ logging.error("IO Error: %s", e)
4140
4241 def ast2_dump(ast2, filename):
4342 try:
4443 dumpfile=file(filename, 'w')
4544 dumpfile.write(ast2.dump(indent_with="\t", indent_level=0))
4645 except IOError,e:
47- print >> sys.stderr, "IO Error:", e,
46+ logging.error("IO Error: %s", e)
4847
4948 def ast2_GV(ast2, filename):
5049 import donjon.aux.graphviz as graphviz
@@ -52,7 +51,7 @@
5251 gvfile=file(filename, 'w')
5352 gvfile.write(graphviz.dumpGV(ast2,header=True))
5453 except IOError,e:
55- print >> sys.stderr, "IO Error:", e,
54+ logging.error("IO Error: %s", e)
5655
5756
5857 def ast2_pickle(ast2, filename):
@@ -64,7 +63,7 @@
6463 pickle.dump(ast2,picklefile, -1)
6564 pickle.dump(CCBase._node_counter,picklefile, -1)
6665 except IOError,e:
67- print >> sys.stderr, "IO Error:", e,
66+ logging.error("IO Error: %s", e)
6867
6968
7069 def ast2_unpickle(ast2_filename):
@@ -77,8 +76,7 @@
7776 CCBase._node_counter = pickle.load(picklefile)
7877 return ast2
7978 except IOError,e:
80- import sys
81- print >> sys.stderr, "IO Error:", e,
79+ logging.error("IO Error: %s", e)
8280
8381
8482 def AST2debug(debug_options):
diff -r de2c99b913e0 -r fd950b81ea5c compiler/py/donjon/sdg/vsymbols.py
--- a/compiler/py/donjon/sdg/vsymbols.py Thu Oct 31 23:20:51 2013 +0100
+++ b/compiler/py/donjon/sdg/vsymbols.py Sat Nov 02 13:08:07 2013 +0100
@@ -9,6 +9,8 @@
99 from donjon.ast.implementation import Implement
1010 from ..ccBase import CCmixInNamed
1111
12+import logging
13+
1214 class VirtSymBase(SDGBase, CCmixInNamed):
1315 __str__ = CCmixInNamed.getName
1416
@@ -49,6 +51,6 @@
4951 elif isinstance(side, Component) and self.component is None:
5052 self.component = side
5153 else:
52- print "ERROR: Can't add %s to correct side of %s vsymbol (%)" % (side, type(self), self.getName())
54+ logging.error("Can't add %s to correct side of %s vsymbol (%)" % (side, type(self), self.getName()))
5355
5456