Improve logging mechanism