Logging Stacktrace To File
Steve Holden
python at holdenweb.com
Tue Apr 13 10:03:21 EDT 2004
Olaf Meding wrote:
> In case of an exception, how could I log an exception to a file on disk?
>
> Much appreciate your help, thank you.
>
> Olaf
>
>
Here's what I use, modulo a certain amount of mangling by Mozilla, which
I am still trying to tame:
def hook(et, ev, eb):
import traceback
log("\n ".join (["Error occurred: traceback
follows"]+list(traceback.format_exception(et, ev, eb))))
sys.excepthook = hook
This works very well, but you'll need to supply your own "log()"
function. Shouldn't be too hard ...
regards
Steve
More information about the Python-list
mailing list