Skip to content
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

Merged
merged 14 commits into from
Oct 20, 2022

Conversation

kealjones-wk
Copy link
Contributor

@kealjones-wk kealjones-wk commented Oct 14, 2022

Motivation

These logs suck and are no help:
Screen Shot 2022-10-14 at 2 18 39 PM

Changes

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@kealjones-wk kealjones-wk requested review from a team and aaronlademann-wf and removed request for a team October 14, 2022 21:48
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a 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 Show resolved Hide resolved
lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
test/unit/console_log_utils_test.dart Outdated Show resolved Hide resolved
lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
@@ -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) {
Copy link
Contributor

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
Copy link
Contributor

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? 😛

Copy link
Contributor Author

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.

Copy link
Contributor

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']);
Copy link
Contributor

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++]]);
Copy link
Contributor

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.

Suggested change
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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a 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();
Copy link
Contributor

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.

consoleRefs[config].apply([message, arg1, arg2, arg3, arg4, arg5], thisArg: self);
});
consolePropertyDescriptors[config] = _getOwnPropertyDescriptor(_console, config);
consoleRefs[config] = context['console'][config];
Copy link
Contributor

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?

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10

lib/src/util/console_log_utils.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a 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

@greglittlefield-wf
Copy link
Contributor

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rmconsole7-wk rmconsole7-wk merged commit 434df25 into master Oct 20, 2022
@rmconsole7-wk rmconsole7-wk deleted the spike-fed-466 branch October 20, 2022 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants