#41 debug logging needs better source code location information
Closed: Fixed None Opened 5 years ago by jdennis.

When you enable debug logging the log.debug() function will automatically include the name of the function which invoked it, for example:

DEBUG(__init__) xxx

But there are many functions/methods which share the same name, that makes the debug information difficult to use unless you know the source code by heart. Which init() method is being called? Which GET() method?

It would really help if the method included it's class name. A method qualified with it's class name adds a lot of context that helps decipher the log file.

It can also be helpful to know the file and line number.

Attached is a git patch to log.py that adds the class to the method name, it also adds file and line information. The file path is trimmed to the last 3 components to keep it short, just enough context to identify the location. Now instead of

DEBUG(__init__): xxx

you'll get something like this:

DEBUG(openid/extensions/common.py:56 LoadExtensions.__init__()): xxx
DEBUG(ipsilon/providers/common.py:129 LoadProviders.__init__()): xxx
DEBUG(ipsilon/login/common.py:162 Form.GET()): xxx

Also included is a config option stacktrace_on_error which will add a stacktrace to the log file when logging a error. It defaults to off. A stacktrace can be really helpful when errors occur.


stacktrace_on_error = True

Fields changed

milestone: => 1.0 m1
owner: simo => puiterwijk
status: new => assigned

available in git://fedorapeople.org/~jdennis/ipsilon.git under the log_location topic branch

Fields changed

owner: puiterwijk => jdennis

Pushed to master:
commit id: 74194d5

patch_available: => 0
resolution: => fixed
status: assigned => closed

Fields changed

rhbz: => 0

Metadata Update from @nkinder:
- Issue assigned to jdennis
- Issue set to the milestone: 1.0 m1

3 years ago

Login to comment on this ticket.