Improve log mechanism