-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
console,doc: add inspector console object #15579
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
assert.ok(process.stdout.writable); | ||
assert.ok(process.stderr.writable); | ||
|
@@ -187,3 +188,16 @@ common.hijackStderr(common.mustCall(function(data) { | |
assert.strictEqual(data.includes('no such label'), true); | ||
}); | ||
})); | ||
|
||
const pristineConsole = vm.runInNewContext('this.console'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you should skip if |
||
for (const name in console.inspector) { | ||
|
||
// No inspector-only functions are available on the global console | ||
if (name in console) { | ||
assert.notStrictEqual(console[name], console.inspector[name]); | ||
} | ||
|
||
// console.inspector should be the same as a pristine console object from a v8 | ||
// context. | ||
assert(name in pristineConsole); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just completely ignore the dummy inspector methods, i.e. do not expose them at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the inspector methods are not provided, users don't have a way of sending any of the messages that aren't also provided by
Console.prototype
to the inspector console.I had originally thought of exposing something like
require('inspector').console
, but I'm not sure that's something I can set up atbootstrap_node.js
time, soconsole.inspector
seemed to be a good second option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bengl I understand that implication. However, I feel it's ugly from a user experience standpoint to require users to use
console.inspector ? console.inspector.table : console.table
in polymorphic code: either it should work the way it does everywhere, or it shouldn't.Also, these console methods only became exposed in 8.0.0, so there isn't much compatibility concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For certain functions that inherently do not deal with stdio, like
console.markTimeline
,console.profile
,console.profileEnd
,console.timeStamp
,console.timeline
, andconsole.timelineEnd
, I think we should just keep them as they are and maybe document them. There isn't any work needed by Node.js' Console to "support" those methods because they are no-ops in the console anyway.That leaves
console.debug
,console.dirxml
, andconsole.table
truly unimplemented Console methods.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimothyGu Is that a "-1" opposition or more a "-0"?