Improve log function.