Do not stringify log messages in the browser console#40265
Merged
Conversation
This will prevent filtering out `pinnedOnly` property.
gzdunek
commented
Apr 5, 2024
ravicious
approved these changes
Apr 8, 2024
Member
There was a problem hiding this comment.
The only thing that worries me is that there's no way to expand all collapsed objects at once. This means that:
- You won't see the output as it comes, e.g. when the app continuously receives some kind of messages from tshd.
- You won't be able to filter by parts of the output that have been collapsed.
The workaround for both of those things would be to simply look at the log file instead. Also, you can use Opt + click to recursively expand any given object, but that still works on only a single object.
I think we should be able to live with that, what do you think?
Contributor
Author
There was a problem hiding this comment.
- Correct, but if the response is more complex, looking for a particular part of it is hard when the message is unformatted.
- I think I've never had a need to look for something in more than one response, so expanding it wouldn't be too much work.
Overall, your points are valid, but the pros still outweigh the cons to me.
You also provided a good workaround, so I think we don't loose anything here.
avatus
approved these changes
Apr 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, all log messages from Connect are stringified with
JSON.stringifyto allow logging complex values like objects or arrays (instead of printing[object Object]). This happens for both file loggers and dev loggers in consoles.The only downside of this is that reading long log messages (like unified resources response) is quite hard.
To improve readability, we can stop stringifying the values for the browser. Instead, we can use
console.*functions to present objects or arrays in a nice, expandable way.Before:

After:

Important
This only affects dev logs in the browser, not file or dev logs in a non-browser console (main process).
I also fixed a bug introduced in #39229, where
pinnedOnlyproperty started to be considered "sensitive". Instead of making partial matching on the key names, we can check the full name.