Hongyi: add a null-checking to each reference of console object to prevent app crash