Recording exceptions on the server

Martin Pool mbp at sourcefrog.net
Tue Jul 7 04:17:54 BST 2009


2009/7/7 Jonathan Lange <jml at mumak.net>:
> I'd like to hook into Bazaar so that any errors raised by the smart
> server get logged in our internal OOPS error handling system.
>
> For many Python applications, the natural way to do this would be to
> add Handler to a Logger object so that any exception() calls get
> turned into OOPS reports.
>
> Bazaar half-uses Python's 'logging' module. bzrlib uses bzrlib.trace,
> which sometimes uses logging and other times does direct file access.
> As best as I can tell, I think I want to record an OOPS every time
> log_exception_quietly is called.

Some of these exceptions are more serious than others, but logging
them all is probably a good start.

> log_exception_quietly calls mutter(traceback.format_exc()). This is
> *almost* the same as _bzr_logger.exception(), except that mutter is
> quieter. exception() would also log an actual error.
>
> I'd like log_exception_quietly to Python logging, but I don't see how
> to make it work -- any ideas?
>
> To address my immediate problem, I'm going to monkey-patch
> log_exception_quietly to directly call our OOPS system.

It turns out that logging actually takes nontrivial time to load and I
think we might be better off without it.  Of course half-using it
doesn't mean we avoid half the cost :-)

I agree with robert about adding a hook for "an exception occurred".
We could also say that "report an error" is a function of the UI, and
Launchpad should use a custom non-interactive UI.  You could do both;
possibly a plugin or apport would want to know about the exception as
well as the UI controlling how it's represented.

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list