如何使node.js日志记录格式的结束参数与开始参数匹配?
最新版本的node如何使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
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的别名。