From f9c72a988bee77efd6a6f3069d3c460fff23c9cc Mon Sep 17 00:00:00 2001 From: necoro <> Date: Sun, 4 Feb 2007 03:09:41 +0000 Subject: Added file support for debug (merged from curses-branch) --- portato/helper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'portato/helper.py') diff --git a/portato/helper.py b/portato/helper.py index 2a492cc..fab8aa5 100644 --- a/portato/helper.py +++ b/portato/helper.py @@ -36,7 +36,10 @@ def debug(*args, **kwargs): if not DEBUG : return stack = traceback.extract_stack() - a, b, c, d = stack[-2] + minus = -2 + if "minus" in kwargs: + minus = minus - kwargs["minus"] + a, b, c, d = stack[minus] a = os.path.basename(a) out = [] for obj in args: @@ -49,7 +52,12 @@ def debug(*args, **kwargs): text = "***DEBUG*** %s ***DEBUG***" % text - print text + if "file" in kwargs: + f = open(kwargs["file"], "a+") + f.write(text+"\n") + f.close() + else: + print text def am_i_root (): """Returns True if the current user is root, False otherwise. -- cgit v1.2.3