feat: toggle unescape strings
WesleyYue opened this issue · comments
Hey, thanks for putting this great tool together. I often run into logs that have some escaped string, like "This is a newline\n". When these strings get long, it's very hard to read, and sometimes they can be multiple levels of escape being nested. I've ran into bugs that I could've solved a lot earlier if I could easily inspect escaped logs.
It would be great if there is a toggle to escape one level (with support for escaping more than one level).
I unfortunately don't have time to contribute atm but leaving a request here in case any one else also has similar needs. Happy to come back and contribute this feature when I have some time.
Hi! Thank you for the issue.
Let's take the following logs:
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
{"message": "123123123123\n123123123123123\n123123123123123"}
How do you want to see this?
Naively, I think just escaping the sequences as is would work. The important thing is changing a long piece of text that's practically unreadable into something that at least has structure. The lack of indentation would be a bit weird, but this is also how Python triple quote strings work so it least has precedance.
Alternatively, something like this might make sense, but I realize this is probably straying a bit far from any JSON conventions
what about expanding such strings on click?
and probably this issue should go to https://github.com/antonmedv/fx (this widget is reused in json-log-viewer).
I think that would be a good UX. Let me post to the fx repo. Thanks :)