how to create line breaks in console.log() in node

后端 未结 7 1569
一生所求
一生所求 2021-01-01 13:11

Is there a way to get new lines in console.log when printing multiple objects?

Suppose we have console.log(a,b,c) where a, b,

7条回答
  •  有刺的猬
    2021-01-01 13:23

    An alternative is creating your own logger along with the original logger from JS.

    var originalLogger = console.log;
    console.log = function() {
      for (var o of arguments) originalLogger(o);
    }
    
    console.log({ a: 1 }, { b: 3 }, { c: 3 })

    If you want to avoid any clash with the original logger from JS

    console.ownlog = function() {
      for (var o of arguments) console.log(o);
    }
    
    console.ownlog({ a: 1 }, { b: 3 }, { c: 3 })

提交回复
热议问题