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

Changing default options for util.inspect #7566

Closed
silverwind opened this issue Jul 6, 2016 · 3 comments
Closed

Changing default options for util.inspect #7566

silverwind opened this issue Jul 6, 2016 · 3 comments
Labels
console Issues and PRs related to the console subsystem. 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

@silverwind
Copy link
Contributor

console.log and relatives use util.inspect to stringify complex structures, which creates somewhat of a dilemma when you have an application making use of bare console functions but you'd like unrestricted nesting (depth: null) or more than 100 visible array elements ( maxArrayLength: null) by default.

To change the default, I could see util.inspect.setup(opts) being made available. Anyone with me?

@silverwind silverwind added util Issues and PRs related to the built-in util module. feature request Issues that request new features to be added to Node.js. console Issues and PRs related to the console subsystem. labels Jul 6, 2016
@mscdex
Copy link
Contributor

mscdex commented Jul 6, 2016

I think at that point, you should just consider using your own logging function everywhere.

@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

Having some mechanism by which to modify the defaults here makes sense, but I'm not sure we could get consensus around it. An alternate logging function (or monkeypatch for console) would likely be the most productive approach.

@silverwind
Copy link
Contributor Author

Let's see how it goes. Filed #8013.

silverwind added a commit to silverwind/node that referenced this issue Aug 9, 2016
Adds util.inspect.defaultOptions which allows customization of the
default util.inspect options, which is useful for functions like
console.log or util.format which implicitly call into util.inspect.

PR-URL: nodejs#8013
Fixes: nodejs#7566
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
silverwind added a commit that referenced this issue Aug 9, 2016
Adds util.inspect.defaultOptions which allows customization of the
default util.inspect options, which is useful for functions like
console.log or util.format which implicitly call into util.inspect.

PR-URL: #8013
Fixes: #7566
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
cjihrig pushed a commit that referenced this issue Aug 10, 2016
Adds util.inspect.defaultOptions which allows customization of the
default util.inspect options, which is useful for functions like
console.log or util.format which implicitly call into util.inspect.

PR-URL: #8013
Fixes: #7566
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console Issues and PRs related to the console subsystem. 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

3 participants