Improve logging function.