improve and test logging handler