-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Feature request: Add 1-arity built-in function debug(f) for more control over debug output #2111
Labels
Comments
Closed
Closed
pkoppstein
added a commit
to pkoppstein/jq
that referenced
this issue
Jul 13, 2023
This def ensures the output of debug(m1,m2) is kept together. See jqlang#2709 jqlang#2111 jqlang#2112
Merged
pkoppstein
added a commit
to pkoppstein/jq
that referenced
this issue
Jul 13, 2023
This def ensures the output of debug(m1,m2) is kept together. See jqlang#2709 jqlang#2111 jqlang#2112 Update jq.1.prebuilt manual.yml: debug/1: more typos manual.yml: debug/1: typo msgs
pkoppstein
added a commit
to pkoppstein/jq
that referenced
this issue
Jul 13, 2023
This def ensures the output of debug(m1,m2) is kept together. See jqlang#2709 jqlang#2111 jqlang#2112 Update jq.1.prebuilt manual.yml: debug/1: more typos manual.yml: debug/1: typo msgs builtin.jq: spacing
pkoppstein
added a commit
to pkoppstein/jq
that referenced
this issue
Jul 13, 2023
This def ensures the output of debug(m1,m2) is kept together. See jqlang#2709 jqlang#2111 jqlang#2112 Update jq.1.prebuilt manual.yml: debug/1: more typos manual.yml: debug/1: typo msgs builtin.jq: spacing manual.yml: more tweaking
Closed by #2710 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When working on large jq programs, I usually define a function like so:
Example usage:
As you can see, this function does not change it's input, just like 0-arity
debug
, but it prints a filtered value to stderr instead of its entire input. This function is incredibly useful for situations where the value you are printing is too large or complicated to be easily readable.I usually use it when dealing with huge inputs that cannot fit on a single screen, but there are other applications as well. For example, imagine you are working on a jq filter that manipulates unix timestamps. When using debug to see the timestamps that are being processed, you will see unix time.
but that can be hard to read. If you want formatted datetimes instead, you can do
This works, but is verbose, and will have to be undone if you go back and clean up the debug statements. Imagine if you could do
Easier to read, easier to use, easier to undo in the future. You get the same benefits as
with_entries
vsto_entries
/from_entries
.I propose that this function be added to the list of builtins included with jq.
The text was updated successfully, but these errors were encountered: