clean up code style and add log pretty printer