From 7082c61e27142c1c4c55ab925baa8a162637b066 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Mon, 12 Nov 2018 15:52:43 -0600 Subject: Revert "util: change util.inspect depth default" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ac7450a09a4c167cd43c14d7c88721d22f077529. This fully reverts the changes to util.inspect depth. It has caused breakage in logging to existing apps, and even something as simple as `console.log(require)` will cause >1m freezes. I've heard nothing but negative feedback (seriously not a single person has expressed anything positive about this change) and personally i find this change extremely annoying. PR-URL: https://github.com/nodejs/node/pull/24326 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Franziska Hinkelmann Reviewed-By: Michaƫl Zasso Reviewed-By: Ruben Bridgewater Reviewed-By: John-David Dalton --- doc/api/util.md | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'doc/api/util.md') diff --git a/doc/api/util.md b/doc/api/util.md index 89cfc94da3..b687eaf362 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1,4 +1,4 @@ -# Util +# Util @@ -421,7 +421,7 @@ changes: * `depth` {number} Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. To make it recurse up to the maximum call stack size pass `Infinity` or `null`. - **Default:** `20`. + **Default:** `2`. * `colors` {boolean} If `true`, the output will be styled with ANSI color codes. Colors are customizable, see [Customizing `util.inspect` colors][]. **Default:** `false`. @@ -478,23 +478,12 @@ util.inspect(new Bar()); // 'Bar {}' util.inspect(baz); // '[foo] {}' ``` -The following example limits the inspected output of the `paths` property: +The following example inspects all properties of the `util` object: ```js const util = require('util'); -console.log(util.inspect(module, { depth: 0 })); -// Instead of showing all entries in `paths` `[Array]` is used to limit the -// output for readability: - -// Module { -// id: '', -// exports: {}, -// parent: undefined, -// filename: null, -// loaded: false, -// children: [], -// paths: [Array] } +console.log(util.inspect(util, { showHidden: true, depth: null })); ``` The following example highlights the difference with the `compact` option: @@ -510,7 +499,7 @@ const o = { 'foo']], 4], b: new Map([['za', 1], ['zb', 'test']]) }; -console.log(util.inspect(o, { compact: true, breakLength: 80 })); +console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 })); // This will print @@ -524,7 +513,7 @@ console.log(util.inspect(o, { compact: true, breakLength: 80 })); // b: Map { 'za' => 1, 'zb' => 'test' } } // Setting `compact` to false changes the output to be more reader friendly. -console.log(util.inspect(o, { compact: false, breakLength: 80 })); +console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 })); // { // a: [ -- cgit v1.2.3