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
feat: Implement all the web console methods #522
Conversation
8544253
to
8ef289a
Compare
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.
Great stuff
std::string concat = label; | ||
concat += ": "; | ||
concat += std::to_string(duration); | ||
concat += "ns"; |
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.
Typically this seems to work in seconds (node.js) or milliseconds (chrome / deno). With nanoseconds, this is 9 orders of magnitude smaller than milliseconds. Perhaps we should do some rounding or at least add a decimal place?
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.
node.js does dynamic formatting, it will use ms first and then if/when the period increases it will move to seconds/minutes/etc
Firefox always uses ms
Safari always uses fractional ms
I've updated our implementation to always use fractional ms 👍
JS_FN("dir", dir, 0, JSPROP_ENUMERATE), | ||
JS_FN("dirxml", (console_out<Console::LogType::Log>), 0, JSPROP_ENUMERATE), | ||
JS_FN("error", (console_out<Console::LogType::Error>), 0, JSPROP_ENUMERATE), | ||
JS_FN("group", (console_out<Console::LogType::Log>), 0, JSPROP_ENUMERATE), |
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.
Node.js and Deno have an indentation counter for grouping, although doesn't seem to be that valuable a feature to skip for now to me.
return false; | ||
} | ||
size_t length; | ||
auto stack_string = encode(cx, str, &length); |
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.
Great!
// strip quotes for direct string logs | ||
if (source[0] == '"' && source[source.length() - 1] == '"') { | ||
source = source.substr(1, source.length() - 2); | ||
} | ||
if (message.length()) { | ||
message += " "; | ||
message += source; | ||
} else { | ||
message += source; | ||
} |
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.
This pattern is repeated quite a lot, perhaps let's just refactor it into a separate function?
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.
Looks good to me! Just a few suggestions for map query/update patterns.
9d26f5a
to
5198884
Compare
Corrects the function lengths for all the methods to be `0` instead of `1` as all the functions parameters are optional. Adds a Symbol.toStringTag property with a value of `"console"`. Fixes the prototype chain for `globalThis.console` to match the specification. Bringing in implementations for: - console.assert - console.clear - console.count - console.countReset - console.dir - console.dirxml - console.group - console.groupCollapsed - console.groupEnd - console.table - console.time - console.timeLog - console.timeEnd - console.trace
Co-authored-by: Trevor Elliott <telliott@fastly.com>
57057f9
to
43ef438
Compare
Corrects the function lengths for all the methods to be
0
instead of1
as all the functions parameters are optional.Adds a Symbol.toStringTag property with a value of
"console"
.Fixes the prototype chain for
globalThis.console
to match the specification.Bringing in implementations for: