-
Notifications
You must be signed in to change notification settings - Fork 2
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
FED-466: Fix console logs that require formatting #52
Conversation
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
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.
Some comments, but this looks awesome!!
lib/src/util/console_log_utils.dart
Outdated
@@ -152,3 +154,51 @@ class ConsoleConfig { | |||
/// Captures calls to `console.log`, `console.warn`, and `console.error`. | |||
static const ConsoleConfig all = ConsoleConfig._('all'); | |||
} | |||
|
|||
final formatRegExp = RegExp('%[sdj%]'); | |||
String format(dynamic f, List<dynamic> arguments) { |
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 could use a doc comment
|
||
final _formatRegExp = RegExp('%[sdj%]'); | ||
|
||
/// A doc comment |
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.
You want me to close this PR? 😛
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.
🖕 get out of here friday greg its wednesday.
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 is worse than no doc comment lol
// the test package. | ||
final printCalls = recordPrintCalls(() { | ||
printConsoleLogs(() { | ||
callMethod(getProperty(window, 'console'), 'log', ['%s World Number %d! %j', 'Hello']); |
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 like this is missing the jsified argument, the number, and the additional arg
return num.tryParse(arguments[i++].toString()).toString(); | ||
case '%j': | ||
try { | ||
return _jsonStringify([arguments[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.
Since this isn't callMethod, it shouldn't be wrapped in a list.
return _jsonStringify([arguments[i++]]); | |
return _jsonStringify(arguments[i++]); |
@@ -223,8 +267,7 @@ void main() { | |||
if (runtimeSupportsPropTypeWarnings()) { | |||
group('captures errors correctly', () { | |||
test('when mounting', () { | |||
final logs = recordConsoleLogs(() => rtl.render(Sample({'shouldAlwaysBeFalse': true}) as ReactElement), | |||
configuration: ConsoleConfig.error); | |||
final logs = recordConsoleLogs(() => rtl.render(Sample({'shouldAlwaysBeFalse': true}) as ReactElement), configuration: ConsoleConfig.error); |
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 like these got formatted differently by mistake
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.
they bug me... so i re-formatted them in the next commit.
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.
Just a couple more things
@@ -53,7 +55,9 @@ String format(dynamic f, List<dynamic> arguments) { | |||
return num.tryParse(arguments[i++].toString()).toString(); | |||
case '%j': | |||
try { | |||
return _jsonStringify([arguments[i++]]); | |||
final argToStringify = arguments[i++]; | |||
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.
Looks like this and the import were committed by mistake.
lib/src/util/console_log_utils.dart
Outdated
consoleRefs[config].apply([message, arg1, arg2, arg3, arg4, arg5], thisArg: self); | ||
}); | ||
consolePropertyDescriptors[config] = _getOwnPropertyDescriptor(_console, config); | ||
consoleRefs[config] = context['console'][config]; |
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.
Could we restore the cast that was previously here along with the typing on consoleRefs
?
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.
+10
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.
+10 assuming CI is all green
@Workiva/release-management-p |
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.
+1 from RM
Motivation
These logs suck and are no help:
Changes
Release Notes
Review
See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.
QA Checklist
Merge Checklist
While we perform many automated checks before auto-merging, some manual checks are needed: