Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set inspect.defaultOptions using environment variables #12693

Closed
deadbeef84 opened this issue Apr 27, 2017 · 7 comments
Closed

Set inspect.defaultOptions using environment variables #12693

deadbeef84 opened this issue Apr 27, 2017 · 7 comments
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.

Comments

@deadbeef84
Copy link
Contributor

deadbeef84 commented Apr 27, 2017

  • Version: v6.9.1
  • Platform: Linux jesper-UX303LB 4.4.0-72-generic 93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: util

I really like the addition of util.inspect.defaultOptions, but what would be even nicer would be some way to specify these using environment variables. That way no code changes would have to be made to specify these and on a local development machine one could set their default preference easily.

I'm suggesting the following environment variables:

NODE_INSPECT_SHOWHIDDEN
NODE_INSPECT_DEPTH
NODE_INSPECT_COLORS
NODE_INSPECT_CUSTOMINSPECT
NODE_INSPECT_SHOWPROXY
NODE_INSPECT_MAXARRAYLENGTH
NODE_INSPECT_BREAKLENGTH
@vsemozhetbyt vsemozhetbyt added feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module. labels Apr 27, 2017
@mscdex
Copy link
Contributor

mscdex commented Apr 27, 2017

-1 I can see this easily being a slippery slope for a multitude of other options for other core modules as well.

@mscdex mscdex closed this as completed Apr 27, 2017
@mscdex mscdex reopened this Apr 27, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Apr 27, 2017

-1 from me as well.

@Fishrock123
Copy link
Contributor

node -r set-console-options.js

@deadbeef84
Copy link
Contributor Author

deadbeef84 commented Apr 27, 2017

node -r set-console-options.js

Yes, this is what I'm currently using. However, that doesn't work when running projects using tooling (forever, pm2, nodemon, gulp, etc).

@silverwind
Copy link
Contributor

I'd rather do those in a .noderc file, than to add a load of environment variables, but generally it's not really clear to me which set of options shall take precedence. If user-defined options are taken, it can be dangerous because it can alter program behaviour unexpectedly, and if the script-defined options are taken, the user is not really in control which isn't great.

I think we should actually re-evaluate our defaults. I run into depth and maxArrayLength limits very often when debugging in the REPL and I think having more acceptable defaults might be the best option in the long run.

@jasnell
Copy link
Member

jasnell commented Apr 27, 2017

@deadbeef84 ... we just recently landed the NODE_OPTIONS environment variable. That can be used to set a -r whatever.js that should work with each of those tools.

@Trott
Copy link
Member

Trott commented Aug 4, 2017

Hi, @deadbeef84! Thanks for making the feature request and explaining the use case. It sounds like NODE_OPTIONS has this covered so I'm going to close this. If I'm mistaken about that, please comment (or, if GitHub permits, re-open). Thanks!

@Trott Trott closed this as completed Aug 4, 2017
BridgeAR added a commit to BridgeAR/node that referenced this issue Jan 16, 2018
Currently inspecting the BufferList can result a maximum call stack
size error. Adding a individual inspect function prevents this.

PR-URL: nodejs#17907
Refs: nodejs#12693
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this issue Jan 16, 2018
The current default is not ideal in most use cases. Therefore it is
changed to showing unlimited depth in case util.inspect is called
directly. The default is kept as before for console.log and similar.

Using console.dir will now show a depth of up to five and
console.assert / console.trace will show a unlimited depth.

PR-URL: nodejs#17907
Refs: nodejs#12693
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this issue Jan 16, 2018
Since the default for depth is changed to `Infinity` it is logical
to change the %o default to the same as well.

Using %o with `util.format` will now always print the whole object.

PR-URL: nodejs#17907
Refs: nodejs#12693
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this issue Sep 24, 2018
The current default is not ideal in most use cases. Therefore it is
changed to inspect objects to a maximum depth of 20 in case
util.inspect is called with it's defaults. The default is kept at 2
when using console.log() and similar in the repl.

PR-URL: nodejs#17907
Refs: nodejs#12693
BridgeAR added a commit to BridgeAR/node that referenced this issue Sep 24, 2018
Since the default for depth is changed to `20` it is logical
to change the %o default as well. It will now always use the
default depth.

PR-URL: nodejs#17907
Refs: nodejs#12693
BridgeAR added a commit to BridgeAR/node that referenced this issue Oct 2, 2018
The current default is not ideal in most use cases. Therefore it is
changed to inspect objects to a maximum depth of 20 in case
util.inspect is called with it's defaults. The default is kept at 2
when using console.log() and similar in the repl.

PR-URL: nodejs#17907
Refs: nodejs#12693

PR-URL: nodejs#22846
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this issue Oct 2, 2018
Since the default for depth is changed to `20` it is logical
to change the %o default as well. It will now always use the
default depth.

PR-URL: nodejs#17907
Refs: nodejs#12693

PR-URL: nodejs#22846
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

8 participants