-d now automatically infers the Class::method in dbg(), and -d additionally adds a trailing (filename:line) item. debugserver is now moved to -ddd

This commit is contained in:
Chris Jones 2010-01-14 13:15:05 +00:00
parent 1bcbe94e6a
commit 4d216633fc
3 changed files with 22 additions and 3 deletions

View File

@ -58,7 +58,7 @@ if __name__ == '__main__':
WINDOW.show() WINDOW.show()
TERMINAL.spawn_child() TERMINAL.spawn_child()
if OPTIONS.debug > 1: if OPTIONS.debug > 2:
import terminatorlib.debugserver as debugserver import terminatorlib.debugserver as debugserver
# pylint: disable-msg=W0611 # pylint: disable-msg=W0611
import threading import threading

View File

@ -82,6 +82,8 @@ WM_WINDOW_ROLE property on the window')
if options.debug: if options.debug:
util.DEBUG = True util.DEBUG = True
if options.debug >1:
util.DEBUGFILES = True
if options.working_directory: if options.working_directory:
if os.path.exists(os.path.expanduser(options.working_directory)): if os.path.exists(os.path.expanduser(options.working_directory)):

View File

@ -20,14 +20,32 @@ import sys
import gtk import gtk
import os import os
import pwd import pwd
import inspect
# set this to true to enable debugging output # set this to true to enable debugging output
DEBUG = False DEBUG = False
# set this to true to additionally list filenames in debugging
DEBUGFILES = False
def dbg(log = ""): def dbg(log = ""):
"""Print a message if debugging is enabled""" """Print a message if debugging is enabled"""
if DEBUG: if DEBUG:
print >> sys.stderr, log stackitem = inspect.stack()[1]
parent_frame = stackitem[0]
method = parent_frame.f_code.co_name
names, varargs, keywords, local_vars = inspect.getargvalues(parent_frame)
try:
self_name = names[0]
classname = local_vars[self_name].__class__.__name__
except IndexError:
classname = "noclass"
if DEBUGFILES:
line = stackitem[2]
filename = parent_frame.f_code.co_filename
extra = " (%s:%s)" % (filename, line)
else:
extra = ""
print >> sys.stderr, "%s::%s: %s%s" % (classname, method, log, extra)
def err(log = ""): def err(log = ""):
"""Print an error message""" """Print an error message"""
@ -145,4 +163,3 @@ def dict_diff(reference, working):
result[key] = working[key] result[key] = working[key]
return(result) return(result)