Comment 1 for bug 1503049

Revision history for this message
Robert Collins (lifeless) wrote :

This would be lovely to have.

https://docs.python.org/2/library/logging.html#logging.Formatter.format covers the bit in the logging glue where formatting actually happens.

So users can today use a customer formatter already, with a format() method that can do arbitrary stuff (e.g. journal errors to a list , and then have a cleanup call that asserts the list is empty.

Getting at the formatter instance will require a little poking around, and we could certainly make that easier in FakeLogger.

Making this work by default would be great too - for that I think we need:
 - a local subclass for Formatter
 - journal the exceptions to the fixture
 - add a cleanUp that checks the exceptions list is empty
   assertEqual isn't available outside of TestCase, but we can use the Equals matcher directly to format the error nicely and then just raise AssertionError(that string)