add JSON support and use log as the global variable