You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
util.inspect multiline output length limit should be configurable #7305
Version: v4.4.5 Platform: Darwin MacBook-Air.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64 Subsystem: util : util.js#L815:
The limit is 60 . Can this be configurable ?
Or is there any potentially foolproof way to log any type of variables in a single line for logging purposes.
P.S> would be happy to submit PR in desired format if this is is acknowledged.
It would be great to see a PR that adds a property to the options object that allows the user to configure the maximum length, perhaps allowing a setting of 0 to disable the limit.
By setting breakLength to 1, shouldn't this create multiple lines in the output? I'm getting a single line string like this: { color: 'black', 'font-size': '12px', 'font-weight': 'bold' }
@whitneyland I get the following output '{ color: \'black\',\n \'font-size\': \'12px\',\n \'font-weight\': \'bold\' }'. This is correct as the output will only break for each element.
If the documentation is not clear enough about this, could you please open a issue for this?
Setting breakLength to 1 is working, but not for any number more than 80 including Infinity. This can be confirmed if you use console.dir, which will print out all the \n.
@windmaomao I just checked and it does work properly for me. Do you have a concrete example that does not work as expected? And what Node.js version do you use?
@BridgeAR the node version is 14.15.3, but i have tried with couple of different version as well, so it's pretty consistent.
Here's how to reproduce it, if you use the following code and then try to set breakLength to 1, it'll make the array to display as a column, however if you change this number to anything else, I always get a break after 5 items.
If I understood correct, you prefer to deactivate the array grouping functionality. It's possible to set compact = true or compact = 0. It'll stop the grouping functionality but it'll also change a few other formatting aspects.
Activity
Trott commentedon Jun 15, 2016
It would be great to see a PR that adds a property to the
optionsobject that allows the user to configure the maximum length, perhaps allowing a setting of0to disable the limit.util: add an option for configuring break length
util: add an option for configuring break length
whitneyland commentedon Mar 4, 2017
By setting breakLength to 1, shouldn't this create multiple lines in the output? I'm getting a single line string like this:
{ color: 'black', 'font-size': '12px', 'font-weight': 'bold' }
BridgeAR commentedon Dec 28, 2017
@whitneyland I get the following output
'{ color: \'black\',\n \'font-size\': \'12px\',\n \'font-weight\': \'bold\' }'. This is correct as the output will only break for each element.If the documentation is not clear enough about this, could you please open a issue for this?
windmaomao commentedon Dec 20, 2020
Setting
breakLengthto 1 is working, but not for any number more than80includingInfinity. This can be confirmed if you useconsole.dir, which will print out all the\n.BridgeAR commentedon Dec 21, 2020
@windmaomao I just checked and it does work properly for me. Do you have a concrete example that does not work as expected? And what Node.js version do you use?
windmaomao commentedon Dec 21, 2020
@BridgeAR the node version is 14.15.3, but i have tried with couple of different version as well, so it's pretty consistent.
Here's how to reproduce it, if you use the following code and then try to set
breakLengthto 1, it'll make the array to display as a column, however if you change this number to anything else, I always get a break after 5 items.BridgeAR commentedon Dec 21, 2020
If I understood correct, you prefer to deactivate the array grouping functionality. It's possible to set
compact = trueorcompact = 0. It'll stop the grouping functionality but it'll also change a few other formatting aspects.