You might want to check out the log4cpp library, also on sourceforge, and
also originally based on a Java log library log4j. It allows for a
hierarchy of log categories to which log messages can be sent of varying
levels, then the levels and categories for which log messages are actually
recorded, and where, can be configured elsewhere. It has all the features
you mentioned wanting, so it would seem natural to extend cppunit to use
log4cpp to create a log category hierarchy parallel to the testcase
hierarchy. Each test can log messages to its particular category, and
those messages could be logged to a file or to stdout according to a
runtime configuration.
Like you, I also wanted some kind of logging in the tests, so I modified
the TestCase API to allow the setup(), runtest(), and teardown() methods
which accept a Test pointer. The test methods then log messages directly
to the Test object. If Test were modified to support log4cpp as I
mentioned above, then I think you'd have a nice logging counterpart to
cppunit.
I use log4cpp in my projects as well as cppunit, and I've wanted to
contribute changes to cppunit to use log4cpp directly, but I haven't had
time yet.
You can get details (and source) for my modified cppunit here:
http://www.atd.ucar.edu/~granger
See especially the Changes doc:
http://www.atd.ucar.edu/~granger/UnixCppUnit/doc/changes.html
gary
|