summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael E Brown <mebrown@michaels-house.net>2007-11-29 01:56:28 -0600
committerMichael E Brown <mebrown@michaels-house.net>2007-11-29 01:56:28 -0600
commitf2665073160f562035a1d25407e95438c9fafd27 (patch)
treee7305bc97a4a9ba6b84df3289e957b314bda74aa /src
parentd78835610c79ca889fb90ffee54a8c7a742e2938 (diff)
downloadmock-f2665073160f562035a1d25407e95438c9fafd27.tar.gz
mock-f2665073160f562035a1d25407e95438c9fafd27.tar.xz
mock-f2665073160f562035a1d25407e95438c9fafd27.zip
log calling function name properly
Diffstat (limited to 'src')
-rwxr-xr-xsrc/py-libs/trace_decorator.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/py-libs/trace_decorator.py b/src/py-libs/trace_decorator.py
index 6c2743d..3594d0b 100755
--- a/src/py-libs/trace_decorator.py
+++ b/src/py-libs/trace_decorator.py
@@ -32,7 +32,8 @@ def traceLog(logger = moduleLog):
message = message + "%s=%s" % (k,repr(v))
message = message + ")"
- l2.handle(l2.makeRecord(l2.name, logging.DEBUG, filename, lineno, message, args=[], exc_info=None, func=func_name))
+ frame = sys._getframe(2)
+ l2.handle(l2.makeRecord(l2.name, logging.DEBUG, os.path.normcase(frame.f_code.co_filename), frame.f_lineno, message, args=[], exc_info=None, func=frame.f_code.co_name))
try:
result = "Bad exception raised: Exception was not a derived class of 'Exception'"
try:
@@ -61,10 +62,13 @@ if __name__ == "__main__":
def testFunc(arg1, arg2="default", *args, **kargs):
return 42
- try:
- testFunc("hello", "world")
- testFunc("happy", "joy", name="skippy")
- testFunc("hi")
- except:
- import traceback
- traceback.print_exc()
+ testFunc("hello", "world")
+ testFunc("happy", "joy", name="skippy")
+ testFunc("hi")
+
+ @traceLog(log)
+ def testFunc22():
+ return testFunc("archie", "bunker")
+
+ testFunc22()
+