]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/util/aglogging.py
1 #----------------------------------------------------------------------------
3 # Purpose: Utilities to help with logging
9 # Copyright: (c) 2005 ActiveGrid, Inc.
10 # License: wxWindows License
11 #----------------------------------------------------------------------------
21 def setTestMode(mode
):
32 def testMode(normalObj
, testObj
=None):
37 def toDiffableString(value
):
48 i
= s
.find(" at 0x", start
)
51 def removeFileRefs(str):
52 str = re
.sub(r
'(?<=File ")[^"]*(\\[^\\]*")(, line )[0-9]*', _fileNameReplacement
, str)
55 def _fileNameReplacement(match
):
56 return "...%s" % match
.group(1)
59 extype
, val
, tb
= sys
.exc_info()
61 for s
in traceback
.format_tb(tb
):
65 def reportException(out
=None, stacktrace
=False, diffable
=False):
66 extype
, val
, t
= sys
.exc_info()
68 exstr
= removeFileRefs(str(val
))
72 print "Got Exception = %s: %s" % (extype
, exstr
)
74 print >> out
, "Got Exception = %s: %s" % (extype
, exstr
)
76 fmt
= traceback
.format_exception(extype
, val
, t
)