From 67516e14fbffe49c10afead8d0f8af6b5e9fd1e0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 17 Aug 2017 22:41:14 -0700 Subject: [PATCH 1/4] console: implement minimal `console.group()` Node.js exposes `console.group()` and `console.groupEnd()` via the inspector. These functions have no apparent effect when called from Node.js without the inspector. We cannot easily hide them when Node.js is started without the inspector because we support opening the inspector during runtime via `inspector.port()`. Implement a minimal `console.group()`/`console.groupEnd()`. More sophisticated implementations are possible, but they can be done in userland and/or features can be added to this at a later time. (It lacks the `label` argument to `console.group()` right now, for example. How to handle `label`, or even whether to handle it, may become a bikeshed discussion. Landing a minimal implementation first avoids the pitfall of that discussion or a similar discussion delaying the implementation indefinitely.) Refs: https://github.com/nodejs/node/issues/12675 Fixes: https://github.com/nodejs/node/issues/1716 --- doc/api/console.md | 14 ++++++ lib/console.js | 19 ++++++-- test/parallel/test-console-group.js | 76 +++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-console-group.js diff --git a/doc/api/console.md b/doc/api/console.md index 08fcfa027c7bad..3c2a02cb2fdab1 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -286,6 +286,20 @@ If formatting elements (e.g. `%d`) are not found in the first string then [`util.inspect()`][] is called on each argument and the resulting string values are concatenated. See [`util.format()`][] for more information. +### console.group() + + +Increases indentation of subsequent lines by one tab (`\t`). + +### console.groupEnd() + + +Decreases indentation of subsequent lines by one tab (`\t`). + ### console.info([data][, ...args]) -Increases indentation of subsequent lines by one tab (`\t`). +* `label` {any} + +Increases indentation of subsequent lines by two spaces. + +If one or more `label`s are provided, those are printed first without the +additional indentation. ### console.groupEnd() -Decreases indentation of subsequent lines by one tab (`\t`). +Decreases indentation of subsequent lines by two spaces. ### console.info([data][, ...args]) + +An alias for [`console.group()`][]. + ### console.groupEnd()