refactored logging to be lazy-loaded