-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Implement console.group #1716
Comments
This looks to be implemented in all major browsers, so +1 for parity. I think your example is a bit too fancy on whitespace, and we should probably only handle the indentation (2 chars?) and maybe add a character on the first char, like |
What are use-cases for it? I see this method for the first time honestly. |
This looks like it can be done in userland just fine? Is there any thing we need to better support it? Otherwise I'm -1. |
It can be done in userland, but what about compatibilty with scripts using these console methods? They'd unnecessarily error out. |
I think I'm +1 on the general idea, since we already have most other However, I'm not sure about the proposed formatting. Perhaps there is some other layout that might scale better with nesting? Maybe we could (additionally) support some sort of |
I am +1, because we are better to implement same api on browser as possible. DeveloperToolsWG members are trying to standardize node/io.js unimplemented:
node/io.js implemented but different behavior from browsers
We need to define what API should be implemented / should not be implemented. |
It makes logging output much more legible, especially when you have a lot of it. It's particularly useful when you have a function that gets called frequently, and you want to understand how (or if) it's being called from a particular point in your code. It's also very useful for understanding anything that happens recursively, because there's visual structure involved. My words aren't really doing it justice, but it's a bit like going from
That's fair - in fact I'm not really proposing it, as such, it's just what I cobbled together this afternoon. I'm certain it can be improved. Thanks for considering this. I totally understand the preference for userland solutions, though as @Fishrock123 notes it does necessitate monkey-patching. |
👍 just for the parity with browsers. As stated, there does not seem to be official standard for
I think Node should implement something code-compatible with these and then later move to standardized |
Even Microsoft IE/Chakra JS has now |
This should be quite easy to implement. The general consensus seems to be in favor.
As for styling, I'd suggest just two spaces as a start. |
@silverwind Actually
|
Right, misinterpreted that. Should be aliased to |
|
@3y3 would something like this work for console.groupCollapsed = function () {
console.group.apply(console, arguments);
} |
@silverwind , yes, this would work. |
What about indents node would add to the output? |
node-inspector will remove them then (if) this feature will be implemented. |
I correct myself. Node Inspector will receive not formatted messages, in other words, he doesn't need to trim leading spaces. |
Oh, I too forgot that |
I've opened a pull-request #1727 to implement this feature in core lib |
Closing this one. This has come up several times and we keep landing on not pursuing this. |
This is fixed, re-open if anything needs changing. |
@bmeck Do you have a link to a PR/commit? Can't find it (and it's not in 7.1.0). https://github.com/nodejs/node/search?q=%22console.group%22 |
@SimenB oh interesting, it appears when |
It's probably Chrome's |
@SimenB even in node's repl it is replaced, not chrome's,
|
Implemented but it doesn't seem to actually do anything? $ node -v
v8.1.4
$ node -e "console.log(console.group.toString())"
function group() { [native code] }
$ cat test.js
console.log("This is the outer level");
console.group();
console.log("Level 2");
console.group();
console.log("Level 3");
console.warn("More of level 3");
console.groupEnd();
console.log("Back to level 2");
console.groupEnd();
console.log("Back to the outer level");
$ node test.js
This is the outer level
Level 2
Level 3
More of level 3
Back to level 2
Back to the outer level
$ I would expect the groups to at least be indented. |
Interesting, looks like a recent v8 update defined a number |
We cannot do that easily because we support opening inspector during runtime (https://nodejs.org/api/inspector.html#inspector_inspector_open_port_host_wait). We should just implement |
#14910 PR for the most minimal |
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: nodejs#12675 Fixes: nodejs#1716
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. `console.groupCollapsed()` is implemented as an alias for `console.group()`. PR-URL: nodejs/node#14910 Fixes: nodejs/node#1716 Ref: nodejs/node#12675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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. `console.groupCollapsed()` is implemented as an alias for `console.group()`. PR-URL: nodejs/node#14910 Fixes: nodejs/node#1716 Ref: nodejs/node#12675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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. `console.groupCollapsed()` is implemented as an alias for `console.group()`. PR-URL: #14910 Fixes: #1716 Ref: #12675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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. `console.groupCollapsed()` is implemented as an alias for `console.group()`. PR-URL: #14910 Fixes: #1716 Ref: #12675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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. `console.groupCollapsed()` is implemented as an alias for `console.group()`. PR-URL: #14910 Fixes: #1716 Ref: #12675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
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. `console.groupCollapsed()` is implemented as an alias for `console.group()`. PR-URL: #14910 Fixes: #1716 Ref: #12675 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
It might be totally impractical to do this properly, so I'll understand if it's immediately closed as wontfix, but a) it'd be really useful, and b) @domenic sent me here!
Basically, it'd be really great if there was something vaguely equivalent to
console.group
, as it's incredibly useful for debugging in the browser. I whipped up node-console-group which is a very naive implementation (can't handle wrapped lines, etc) but good enough for my current needs - does this seem like something that would be worth fleshing out and adding to io.js?The text was updated successfully, but these errors were encountered: