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

Improved scratchpad (xml, json, base64 etc.) #119

Open
variar opened this issue Oct 12, 2019 · 9 comments
Open

Improved scratchpad (xml, json, base64 etc.) #119

variar opened this issue Oct 12, 2019 · 9 comments

Comments

@variar
Copy link
Owner

variar commented Oct 12, 2019

[email protected]
Hi,
they have this useful feature there and also a small build it xml viewer which we can open a large xml line in a log and read it in a more human format

Other scratchpad suggestions are welcome in this issue.

@wiz0u
Copy link

wiz0u commented Nov 12, 2019

I don't know if the scratchpad in build 500 is toward this request, but this nifty little scratchpad could become more useful:

  • Add "Encode Base64" and "Format XML"
  • Make "Format JSON" work (it doesn't seem right now)
  • Restrict encode/decode/format to current selection if any
  • Remember last text content and window position/size of the scratchpad
  • Have "Format JSON" leave as-is any text that appears before the first opening bracket and after the detected end bracket of the JSON content
    (xyz { ... } zyx)
  • Right-click on lines in the main window and choose "Append to scratchpad" in the context menu

@wiz0u
Copy link

wiz0u commented Nov 12, 2019

Although I think these enhancements might have less priority than other useful bugfix or features.

@variar
Copy link
Owner Author

variar commented Nov 12, 2019

Thanks for useful feedback. It is still early work in progress. I just had to do a lot of base64 -> json recently and composed this little tool. Will make it more useful but with less priority.

@variar variar added this to the 2019.next milestone Nov 12, 2019
@variar variar self-assigned this Dec 5, 2019
@variar
Copy link
Owner Author

variar commented Dec 6, 2019

Add url decoding support

@wiz0u
Copy link

wiz0u commented Jan 13, 2020

"Format xml" in Scratchpad has an issue if first root node is an XML declaration like <?xml version="1.0" encoding="utf-8" ?> then the rest is removed. This may be solved by my 2nd remark:
Even if it is invalid XML, I think you should not simply keep the first root node and remove the rest, but keep & format the following root nodes as well (some logging software may output consecutive root XML chunks)

@wiz0u
Copy link

wiz0u commented Jan 13, 2020

Button CRC32 could be a "direct button with a split drop-down menu on the right side" offering MD5, SHA1 and SHA256 as well. Also I think this button should present the result as a MsgBox and place the checksum in the clipboard, rather than replace the content of the scratchpad.

@variar variar changed the title Add xml/json viewing Improved scratchpad (xml, json, base64 etc.) Jan 13, 2020
@variar variar modified the milestones: 2021.next, 2021.06 Jan 27, 2021
@variar variar modified the milestones: 2021.06, 2021.next May 2, 2021
@eNcacz
Copy link

eNcacz commented May 23, 2023

Idea

It would be nice to have a way to "unescape" a string. Namely, I want to replace

  • \n by new line
  • \t by tab
  • \" by "

It will be useful for long formatted strings serialized in the json attribute.

Test case

Let's have this log line:

{"@timestamp":"2023-05-18 21:22:35,588","level":"ERROR","message":"Exception caught in mainLoop: Response not obtained in 20 seconds","exc_info":"Traceback (most recent call last):\nFile \"/venv/lib/python3.10/site-packages/trio/_threads.py\", line 215, in to_thread_run_sync\n  return await trio.lowlevel.wait_task_rescheduled(abort)\nFile \"/venv/lib/python3.10/site-packages/trio/_core/_traps.py\", line 166, in wait_task_rescheduled\n  return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()\nFile \"/venv/lib/python3.10/site-packages/outcome/_impl.py\", line 138, in unwrap\n  raise captured_error\nResponseTimeout: Response not obtained in 20 seconds","thread":"MainThread"}

If I send it to the scratchpad and press the "Format json" button, then I will get

{
    "@timestamp": "2023-05-18 21:22:35,588",
    "exc_info": "Traceback (most recent call last):\nFile \"/venv/lib/python3.10/site-packages/trio/_threads.py\", line 215, in to_thread_run_sync\n  return await trio.lowlevel.wait_task_rescheduled(abort)\nFile \"/venv/lib/python3.10/site-packages/trio/_core/_traps.py\", line 166, in wait_task_rescheduled\n  return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()\nFile \"/venv/lib/python3.10/site-packages/outcome/_impl.py\", line 138, in unwrap\n  raise captured_error\nResponseTimeout: Response not obtained in 20 seconds",
    "level": "ERROR",
    "message": "Exception caught in mainLoop: Response not obtained in 20 seconds",
    "thread": "MainThread"
}

It already works.

Then, when I select the "exc_info" attribute value ...

Traceback (most recent call last):\nFile \"/venv/lib/python3.10/site-packages/trio/_threads.py\", line 215, in to_thread_run_sync\n  return await trio.lowlevel.wait_task_rescheduled(abort)\nFile \"/venv/lib/python3.10/site-packages/trio/_core/_traps.py\", line 166, in wait_task_rescheduled\n  return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()\nFile \"/venv/lib/python3.10/site-packages/outcome/_impl.py\", line 138, in unwrap\n  raise captured_error\nResponseTimeout: Response not obtained in 20 seconds

... and press the new (desired) "Unescape" button, I want it to be replaced with this text:

Traceback (most recent call last):
File "/venv/lib/python3.10/site-packages/trio/_threads.py", line 215, in to_thread_run_sync
  return await trio.lowlevel.wait_task_rescheduled(abort)
File "/venv/lib/python3.10/site-packages/trio/_core/_traps.py", line 166, in wait_task_rescheduled
  return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()
File "/venv/lib/python3.10/site-packages/outcome/_impl.py", line 138, in unwrap
  raise captured_error
ResponseTimeout: Response not obtained in 20 seconds

Thanks for the work on klogg. I'm excited about how much better it is than the original glogg.

@variar
Copy link
Owner Author

variar commented May 25, 2023

Nice idea!

@variar variar modified the milestones: 2023.09, 2024.next Jul 1, 2023
@variar
Copy link
Owner Author

variar commented Jul 1, 2023

Need to revisit and split into separate issues

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

No branches or pull requests

3 participants