Skip to content

Commit

Permalink
dev: Show error messages with jq's short filter
Browse files Browse the repository at this point in the history
  Just displaying the message of the log line is usually not enough to
  get a sense of what went wrong when we logged an error so displaying
  the error's `message` attribute as well would help.

  It's also an easy way to spot errors amidst other messages when using
  the `short` filter.
  • Loading branch information
taratatach committed Nov 13, 2024
1 parent 9dc3d98 commit fa6d1dd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .jq
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ def doc:
# yarn -s jq -c 'select(...)|short' path/to/logs*
#
def short:
{time,component,msg,_id,path,oldpath,event}
{time,component,msg,_id,path,oldpath,event,err}
| if (.event | not) then del(.event) else . end
| if (.event | type == "object") then del(.event) + (.event|{path, oldpath: .oldPath, action}) else . end
| if (.err | not) then del(.err) else . end
| if (.err | type == "object") then del(.err) + {err:.err.message} else . end
| del(.. | nulls)
;

Expand Down

0 comments on commit fa6d1dd

Please sign in to comment.