Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add debug/1 to log debug messages without consuming stdin
Define `debug/1` to call `debug/0`, but send `stdin` to `stdout` without consuming it, while printing the debug messages to `stderr`. Example usage: ```sh seq 2 | LOG_LEVEL=DEBUG jq ' debug({$ENV}) | debug({line: input_line_number}) | debug("\(now | todate) here1: .=\(.)") | . * 10 | debug("\(now | todate) here2: .=\(.)") | . + 1 ' ``` => ``` ["DEBUG:",{"ENV":{"PWD":"/tmp","SHELL":"/bin/zsh","PATH":"/usr/bin:/bin", ...}}] ["DEBUG:",{"line":1}] ["DEBUG:","2022-09-03T10:52:24Z here1: .=1"] ["DEBUG:","2022-09-03T10:52:24Z here2: .=10"] 11 ["DEBUG:",{"ENV":{"PWD":"/tmp","SHELL":"/bin/zsh","PATH":"/usr/bin:/bin", ...}}] ["DEBUG:",{"line":2}] ["DEBUG:","2022-09-03T10:52:24Z here1: .=2"] ["DEBUG:","2022-09-03T10:52:24Z here2: .=20"] 21 ``` ie. a *slightly* less efficient way of achieving: ```sh seq 2 | jq ' . * 10 | . + 1 ' ``` => ``` 11 21 ```
- Loading branch information