Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5834

Custom logging reports wrong line number?

$
0
0

@bmartin wrote:

Hello,

For designing a special product, we have many (over 20) of Python scripts. To simplify trouble shooting, we use the logging Python module. Because it was difficult to control the activation/deactivation of the logging and the level of detail of the whole process over that many files (on file could have logging deactivated, another logging only errors, etc.), I wrote another module which regroup all the calls to the basic logging Python library, relying on the sys._getframe() method to get the caller line of code (otherwise I would always get my log function line number which kind of defeats the logging purpose!).

At first it seems to work but I found that it only reported the right line number when I run it from the Rhino Python Editor WITH a break point somewhere in the code (and continuing afterward). Without hitting a breakpoint (just pressing Play), it would always report the line 1!

Can anyone tell me:

  1. Why the Python sys._getframe() call behaves differently wether there is a breakpoint present or not.
  2. What can I do to fix it?

Regards,

P.S.: Attached are example of logging results I get with/without breakpoint and a streamlined version of my custom logging module (just run it in the Python Editor to reproduce the problem)

Bruno

MyLog_Bad_NoBreakPoint.txt (199 Bytes)
MyLog_Good_BreakpointAndContinue.txt (199 Bytes)
MyLogging.py (1.2 KB)

Posts: 9

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 5834

Latest Images

Trending Articles



Latest Images