Logging api

Refactorings to support testing logging interface. @bernerdschaefer @peterbourgon 
duplicate comment of above