Node.js console.log vs console.info

后端 未结 10 1179
青春惊慌失措
青春惊慌失措 2021-01-30 15:51

What is the benefit of using console.log vs console.info? Or any of the other console commands for that matter?

console.info(\"info\")         


        
10条回答
  •  被撕碎了的回忆
    2021-01-30 16:07

    According to the documentation that you linked to, console.error and console.warn outputs to stderr. The others output to stdout.

    If you are doing piping or redirection from node.js the difference is important.

    There is a lot of JavaScript written to run in both the browser and Node.js. Having node implement the full console allows for greater code cross-compatibility.

    In most browsers, not only do these log in different colors, but you can also filter to see specific messages.

    console.info("info");
    console.error("error");
    console.warn("warn");
    console.log("log");
    

提交回复
热议问题