Logging api

Refactorings to support testing logging interface.