refactoring logging mechanism