Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使node.js日志记录格式的结束参数与开始参数匹配?_Node.js_Logging_Formatting_Parentheses - Fatal编程技术网

如何使node.js日志记录格式的结束参数与开始参数匹配?

如何使node.js日志记录格式的结束参数与开始参数匹配?,node.js,logging,formatting,parentheses,Node.js,Logging,Formatting,Parentheses,最新版本的nodeconsole.log(object)return: { top: { child: { anotherChild: 'someValue' } } } 我如何让它返回一个更传统的: { top: { child: { anotherChild: 'someValue' } } } 谢谢 我可能误解了这个问题。。。有什么原因不能使用JSON.strinfigy格式化对象,然后使用console.log

最新版本的node
console.log(object)
return:

{ top: 
  { child: 
    { anotherChild: 'someValue' } } }
我如何让它返回一个更传统的:

{ 
  top: { 
    child: { 
      anotherChild: 'someValue'  
    } 
  } 
}

谢谢

我可能误解了这个问题。。。有什么原因不能使用
JSON.strinfigy
格式化对象,然后使用
console.log
接受控制缩进级别的附加参数

> a = { top: { child: { anotherChild: 'someValue' } } }
> console.log(JSON.stringify(a, null, 2))

{
  "top": {
    "child": {
      "anotherChild": "someValue"
    }
  }
}

stringify(值[,替换符[,空格]])

特别是

空间可选

一个字符串或数字对象,用于在输出JSON字符串中插入空格以便于可读。如果这是一个数字, 指示用作空白的空格字符数; 如果这个数字大于10,则上限为10。值小于 1表示不应使用任何空间。如果这是一个字符串,则 字符串(或字符串的前10个字符,如果长度大于 用作空白。如果未提供此参数(或 null),不使用空白


我可能误解了这个问题。。。有什么原因不能使用
JSON.strinfigy
格式化对象,然后使用
console.log
接受控制缩进级别的附加参数

> a = { top: { child: { anotherChild: 'someValue' } } }
> console.log(JSON.stringify(a, null, 2))

{
  "top": {
    "child": {
      "anotherChild": "someValue"
    }
  }
}

stringify(值[,替换符[,空格]])

特别是

空间可选

一个字符串或数字对象,用于在输出JSON字符串中插入空格以便于可读。如果这是一个数字, 指示用作空白的空格字符数; 如果这个数字大于10,则上限为10。值小于 1表示不应使用任何空间。如果这是一个字符串,则 字符串(或字符串的前10个字符,如果长度大于 用作空白。如果未提供此参数(或 null),不使用空白


您是否尝试过类似于
util.inspect
?您是否尝试过类似于
util.inspect
?对如果可能的话,我希望更改console日志的行为,而不必创建一个调用console.log.Yes的别名。如果可能的话,我希望更改console日志的行为,而不必创建一个调用console.log的别名。