factor out a lot of log cruft into a base class.