Modify functions to show log on error.
Add function to show log.
Some optimize.