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

Enhance Console logs #846

Merged
merged 25 commits into from
Dec 17, 2024
Merged

Enhance Console logs #846

merged 25 commits into from
Dec 17, 2024

Conversation

maciekstosio
Copy link
Contributor

@maciekstosio maciekstosio commented Dec 12, 2024

This PR aims to improve the debugging experience by making it similar to Chrome DevTools.

It improves the preview, formatting and truncating of console logs and splits large arrays into smaller changes, where chunks are fetched on expand - similarly as vscode-js-debug does. The more detailed previews are generated based on preview property from the debugger, so it may not work on older RN versions.

The main idea was not to reinvent the wheel but to reuse as much of https://github.com/microsoft/vscode-js-debug as possible. Thus we forked it with small patch software-mansion-labs/vscode-js-debug@a579416 that allows us to build it - otherwise the TS on our side failed. vscode-js-debug sits in our repo as a git submodule and no additional steps should be necessary (preinstall script should take care of pulling it, installing and building).

Before After
logs-before logs-after
Before After
large-arrays-before large-arrays-after

How Has This Been Tested:

Update printLogs method with:

function printLogs() {
    const string = 'string';
    const object = { key: 'value', key2: 'value2' };
    const set = new Set([1, 2, 3, 3]);
    const array1000 = new Array(1000).fill(0).map((_, i) => i);
    const array101 = new Array(101).fill(0).map((_, i) => array1000);
    const int = 1;
    const float = 1.1;
    const func = function() {};
    const anonymousFunc = () => {};

    console.log(string, array1000, array101, object, set,
      int,
      float,
      func,
      anonymousFunc);
}

Tested on react-native-76, react-native-73.

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 10:12pm

@maciekstosio maciekstosio changed the title start progress on enhanced logging Enhance Console logs Dec 16, 2024
Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

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

Left some comments inline.

What I don't see how this PR addresses which was one of the main motivators for doing this is how do we deal with large strings. Is it entirely handled by the imported methods from vscode-js-debug?

packages/vscode-extension/package.json Outdated Show resolved Hide resolved
packages/vscode-extension/src/debugging/templates/index.ts Outdated Show resolved Hide resolved
packages/vscode-extension/src/debugging/DebugAdapter.ts Outdated Show resolved Hide resolved
);
}

if (args.filter !== "indexed" && args.filter !== "named") {
Copy link
Member

Choose a reason for hiding this comment

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

maybe this should be an else if given we exclude "indexed" here. Also what happens when "named" is used as this doesn't seem to be handled at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in: 5c1db41

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

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

Looks good!

packages/vscode-extension/src/debugging/DebugAdapter.ts Outdated Show resolved Hide resolved
@maciekstosio maciekstosio merged commit 58b15ca into main Dec 17, 2024
4 checks passed
@maciekstosio maciekstosio deleted the @maciekstosio/Improve-console branch December 17, 2024 22:14
filip131311 added a commit that referenced this pull request Dec 18, 2024
This PR fixes an issue that occurred on fresh clones of the repository.
In #846 we added a new submodule `vscode-js-debug` along with preinstall
actions that should build it. This PR adds initialization to that flow
so the command works on fresh clones as well.

### How Has This Been Tested: 

run:
- `git clone [email protected]:software-mansion/radon-ide.git` 
- `cd packages/vscode-extension`
- `npm i` 

everything should work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants