-
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
lib,src: Ensure '(node:pid)' prefix for stdout logging #3833
Conversation
If there aren't any reason template string can't be used in these files maybe this would be a good time to do that switch for these lines? |
I would recommend moving this to function in internal/util and use template strings as suggested by @martfors |
@thefourtheye will do :) |
The square brackets don't really add anything useful. I would format it as |
@bnoordhuis Thanks :) |
@@ -1641,7 +1643,7 @@ Interface.prototype.trySpawn = function(cb) { | |||
process._debugProcess(pid); | |||
} catch (e) { | |||
if (e.code === 'ESRCH') { | |||
console.error(`Target process: ${pid} doesn't exist.`); | |||
console.error(prefix + pid + `Target process: ${pid} doesn't exist.`); |
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.
Careful here, pid
is defined in this inner scope, overshadowing your top-scope definition. Won't be an issue when you use a function, though :)
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.
@silverwind Yup, I will use a function :)
@thefourtheye Thanks, updated :) |
@@ -232,7 +233,7 @@ EventEmitter.prototype.addListener = function addListener(type, listener) { | |||
m = $getMaxListeners(this); | |||
if (m && m > 0 && existing.length > m) { | |||
existing.warned = true; | |||
console.error('(node) warning: possible EventEmitter memory ' + | |||
iutil.printStdoutError('warning: possible EventEmitter memory ' + | |||
'leak detected. %d %s listeners added. ' + |
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.
The string should align with the previous line's string.
@bnoordhuis |
I would think that |
Yes, the |
Oh wait, are we changing the prefix for everything? In that case, I am good with |
@silverwind @bnoordhuis @thefourtheye Thanks, updated 😄 |
@@ -31,8 +32,8 @@ exports.start = function(argv, stdin, stdout) { | |||
stdin.resume(); | |||
|
|||
process.on('uncaughtException', function(e) { | |||
console.error("There was an internal error in Node's debugger. " + | |||
'Please report this bug.'); | |||
internalUtil.error("There was an internal error in Node's debugger. " + |
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.
We normally use '
for string literals, but in this case it is okay, I guess.
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.
@thefourtheye Because of '
in Node's
, we can't use '
for string literals in this case.
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'd prefer we just escape the apostrophe like so:
'There was an internal error in Node\'s debugger. '
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.
Or alternatively, just use a template string.
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.
@Fishrock123 Thanks :)
Overall change LGTM |
@thefourtheye updated :) |
Can you run
|
@@ -205,7 +205,7 @@ static void ares_sockstate_cb(void* data, | |||
} else { | |||
/* read == 0 and write == 0 this is c-ares's way of notifying us that */ | |||
/* the socket is now closed. We must free the data associated with */ | |||
/* socket. */ | |||
/* the socket. */ |
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.
Is this really necessary as part of this PR?
@jasnell @thefourtheye finished and rebased, Thanks :) |
@@ -1737,7 +1738,7 @@ Interface.prototype.trySpawn = function(cb) { | |||
function connectError() { | |||
// If it's failed to connect 10 times then print failed message | |||
if (connectionAttempts >= 10) { | |||
console.error(' failed, please retry'); | |||
internalUtil.error(' failed to connect, please retry'); |
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.
Not sure about the context of this error, but the message change seems unnecessary.
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.
@silverwind Editing this error message is suggested by @thefourtheye
I think this error message could be more descriptive. If you like to do it, you can do it now.
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.
Ah, alright. Guess it's ok then :)
LGTM. What happened to the C++ ambitions? |
@silverwind I found that the problem was not from C++,but there was a mistake in |
Searching for |
I've added more C++ files in |
@@ -20,7 +20,7 @@ if (process.argv[2] === 'child') { | |||
execFile(process.execPath, args, function(err, stdout, stderr) { | |||
assert.equal(err, null); | |||
assert.equal(stdout, ''); | |||
if (/^WARNING[\s\S]*fs\.readFileSync/.test(stderr)) | |||
if (/^[\s\S]*fs\.readFileSync/.test(stderr)) |
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'd suggest you just remove the ^
here, so the regex is /WARNING[\s\S]*fs\.readFileSync/
.
@silverwind Thanks, fixed :) |
@@ -813,7 +813,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) { | |||
return env->ThrowError("DH parameter is less than 1024 bits"); | |||
} else if (size < 2048) { | |||
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING( | |||
env->isolate(), "WARNING: DH parameter is less than 2048 bits")); | |||
env->isolate(), "(node) WARNING: DH parameter is less than 2048 bits")); |
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.
Can we get a PID here too?
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.
@silverwind this gets logged in here, which is already handled in js code :)
updated and finished :) |
env->isolate(), "WARNING: DH parameter is less than 2048 bits")); | ||
} | ||
env->isolate(), "WARNING: DH parameter is less than 2048 bits")); | ||
} |
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.
Remove the added spaces 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.
Yep, I am doing that :)
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.
Btw, git reset origin/master src/node_crypto.cc
could help in resetting just that file :)
@silverwind fixed, thanks :) |
add '(node:pid)' prefix message for stdout logging
Failures are unrelated, LGTM |
LGTM |
Add '(node:pid)' prefix message for stdout logging PR-URL: #3833 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Landed in 94b9948 |
marking as semver-major so it doesn't get caught up in v5.x, I think that's appropriate, please correct me if I'm wrong. |
@rvagg well, it could certainly break things that parse our stdout, so I guess it's fine to conservatibely label it as major. |
Add '(node:pid)' prefix message for stdout logging PR-URL: nodejs#3833 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Fixes issue: #3789
add '(node:pid)' prefix message for stdout logging