-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
inspector: add inspector console support for native Console #7988
Conversation
@@ -3299,6 +3338,15 @@ void SetupProcessObject(Environment* env, | |||
env->SetMethod(process, "_setupPromises", SetupPromises); | |||
env->SetMethod(process, "_setupDomainUse", SetupDomainUse); | |||
|
|||
#if HAVE_INSPECTOR | |||
// process.inspector | |||
if (use_inspector) { |
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 like to suggest moving this block (and 2 functions above) into inspector_agent.{h,cc} - this way there will be less conditional compilation to maintain.
/cc @dgozman |
Wouldn't it be possible to instead store copies of the original console functions, which would allow us to avoid having to modify |
I addressed your comments and moved all changes into inspector_agent.cc and bootstrap_node.js. |
} | ||
|
||
v8::Local<v8::Array> array = v8::Array::New(env->isolate()); | ||
for (int i = 0; i < args.Length(); ++i) { |
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.
Let's check that arguments are functions here.
Addressed all comments, please take another look! |
if (process.inspector) { | ||
inspectorConsole = global.console; | ||
wrapConsoleCall = process.inspector.wrapConsoleCall; | ||
delete process.inspector.sequentally; |
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.
Still a s/sequentally/sequentially/ typo here.
Environment* env = Environment::GetCurrent(args); | ||
|
||
if (args.Length() != 3 || !args[0]->IsFunction() | ||
|| !args[1]->IsFunction() || !args[2]->IsObject()) { |
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.
Nit: operator should go on previous line.
addressed comments, please take another look. |
} | ||
|
||
node_method.As<v8::Function>()->Call(context, info.Holder(), call_args.size(), | ||
call_args.data()); |
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.
Nit: arguments should line up.
LGTM with a suggestion and a nit. CI: https://ci.nodejs.org/job/node-test-pull-request/3559/ |
Thanks! All done. It looks like freebsd test failure doesn't relate to this pull request. |
LGTM |
if (process.inspector) { | ||
inspectorConsole = global.console; | ||
wrapConsoleCall = process.inspector.wrapConsoleCall; | ||
delete process.inspector.wrapConsoleCall; |
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 prefer if inspector
wasn't a public property on process
(except during startup). Could you get away with deleting process.inspector
here?
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 can remove process.inspector here. Done.
All done. Please take another look! |
LGTM. New CI: https://ci.nodejs.org/job/node-test-pull-request/3580/. |
if (!inspectorConsole.hasOwnProperty(key)) | ||
continue; | ||
// If node console has the same method as inspector console, | ||
// then wrap this two methods into one. Native wrapper will preserve |
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.
grammar nit: "then wrap these two 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.
Also, "will preserve the original stack"
Thanks for review. |
|
||
if (args.Length() != 3 || !args[0]->IsFunction() || | ||
!args[1]->IsFunction() || !args[2]->IsObject()) { | ||
return env->ThrowError("Bad argument."); |
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.
Would prefer the error message to be a bit more descriptive
LGTM with a nit |
Done. |
This time it was failed on https://ci.nodejs.org/job/node-compile-windows/3631/label=win-vs2015/console . It looks like it doesn't relate to my change, does it? |
That seems to be infrastructure related. Windows did pass on the previous build. I think this is good to land. I will do so tomorrow. |
When node is running with --inspect flag, default console.log, console.warn and other methods call inspector console methods in addition to current behaviour (dump formatted message to stderr and stdout). Inspector console methods forward message to DevTools and show its in DevTools Console with DevTools formatters. Inspector console methods not presented on Node console will be added into it. Only own methods on global.console object will be changed while debugging session. User still able to redefine it, use console.Console or change original methods on Console.prototype.
I've rebased this pull request to resolve conflicts. |
Thanks, landed as f6070a1. |
When node is running with --inspect flag, default console.log, console.warn and other methods call inspector console methods in addition to current behaviour (dump formatted message to stderr and stdout). Inspector console methods forward message to DevTools and show up in DevTools Console with DevTools formatters. Inspector console methods not present on Node console will be added into it. Only own methods on global.console object will be changed while in a debugging session. User are still able to redefine it, use console.Console or change original methods on Console.prototype. PR-URL: #7988 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
When node is running with --inspect flag, default console.log, console.warn and other methods call inspector console methods in addition to current behaviour (dump formatted message to stderr and stdout). Inspector console methods forward message to DevTools and show up in DevTools Console with DevTools formatters. Inspector console methods not present on Node console will be added into it. Only own methods on global.console object will be changed while in a debugging session. User are still able to redefine it, use console.Console or change original methods on Console.prototype. PR-URL: #7988 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
console
Description of change
When node is running with --inspect flag, default console.log,
console.warn and other methods call inspector console methods in
addition to current behaviour (dump formatted message to stderr
and stdout). Inspector console methods forward message to DevTools and
show its in DevTools Console with DevTools formatters. Inspector console
methods not presented on Node console will be added into it.
Only own methods on global.console object will be changed while
debugging session. User still able to redefine it, use console.Console
or change original methods on Console.prototype.