-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:
parent
1bcbe94e6a
commit
4d216633fc
|
@ -58,7 +58,7 @@ if __name__ == '__main__':
|
|||
WINDOW.show()
|
||||
TERMINAL.spawn_child()
|
||||
|
||||
if OPTIONS.debug > 1:
|
||||
if OPTIONS.debug > 2:
|
||||
import terminatorlib.debugserver as debugserver
|
||||
# pylint: disable-msg=W0611
|
||||
import threading
|
||||
|
|
|
@ -82,6 +82,8 @@ WM_WINDOW_ROLE property on the window')
|
|||
|
||||
if options.debug:
|
||||
util.DEBUG = True
|
||||
if options.debug >1:
|
||||
util.DEBUGFILES = True
|
||||
|
||||
if options.working_directory:
|
||||
if os.path.exists(os.path.expanduser(options.working_directory)):
|
||||
|
|
|
@ -20,14 +20,32 @@ import sys
|
|||
import gtk
|
||||
import os
|
||||
import pwd
|
||||
import inspect
|
||||
|
||||
# set this to true to enable debugging output
|
||||
DEBUG = False
|
||||
# set this to true to additionally list filenames in debugging
|
||||
DEBUGFILES = False
|
||||
|
||||
def dbg(log = ""):
|
||||
"""Print a message if debugging is enabled"""
|
||||
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 = ""):
|
||||
"""Print an error message"""
|
||||
|
@ -145,4 +163,3 @@ def dict_diff(reference, working):
|
|||
result[key] = working[key]
|
||||
|
||||
return(result)
|
||||
|
||||
|
|
Loading…
Reference in New Issue