-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Implement console.trace() #2780
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
Conversation
js/console.ts
Outdated
const message = stringifyArgs(args, { | ||
indentLevel: this.indentLevel, | ||
collapsedAt: this.collapsedAt, | ||
noTrailingNewline: true |
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.
Why is noTrailingNewline necessary?
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.
It is just that without this settings there will be a newline appended to message by stringifyArgs
and thus leaving a blank line between message and trace on printing err.stack
.
(There is definitely no specification saying this is not allow, just I feel it would be kind of ugly...)
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 appreciate it being formatted as you have it.
Rather, I'm suggesting that instead of adding noTrailingNewline, you make it so stringifyArgs doesn't add a trailing \n and lift that into the existing callers.
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 reviewed the structure of console.ts
and realized that there are some complexity introduced by console.groupCollapsed()
. I believe the original intention of introducing it was to allow synchronous write to stdout, which is available now since we added File::writeSync
.
Technically console.groupCollapsed()
behavior we have is non-standard, as the definition of being collapsed
refers to something like a dropdown. Node simply aliases groupCollapsed
to group
If we were to make console.groupCollapsed
to alias console.group
, then things could simplify quite a bit.
… out of stringifyArgs, fix console.dir, add tests, and fix a repl log quirk For repl logging quirks, I believe we should not indent repl logging. If we really want such indentation, we probably also want to indent "> " prompts.
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.
LGTM - nice clean up with this added feature.
Noticed that we have never implemented this.
https://console.spec.whatwg.org/#trace