]>
code.delx.au - pymsnt/blob - src/debug.py
1 # Copyright 2004-2005 James Bunton <james@delx.cjb.net>
2 # Licensed for distribution under the GPL version 2, check COPYING for details
4 from twisted
.python
import log
12 def __init__(self
, category
=INFO
, ident
="", msg
="", log
=True):
13 self
.category
, self
.ident
, self
.msg
= category
, ident
, msg
14 frame
= sys
._getframe
(1)
16 s
= str(frame
.f_locals
.get("self", frame
.f_code
.co_filename
))
17 self
.klass
= s
[s
.find(".")+1:s
.find(" ")]
18 self
.method
= frame
.f_code
.co_name
19 self
.args
= frame
.f_locals
25 for key
in self
.args
.keys():
27 args
["self"] = "instance"
33 args
[key
] = "Oversize arg"
35 # If its not an object with length, assume that it can't be too big. Hope that's a good assumption.
37 category
= str(self
.category
).split(".")[1]
38 return "%s :: %s :: %s :: %s :: %s :: %s" % (category
, str(self
.ident
), self
.msg
, self
.method
, str(self
.klass
), str(args
))