JS: make console.log safe