Refactored logging mechanism