-
-
Save tobiashochguertel/a039426fa17cdd81f822556ad878111c to your computer and use it in GitHub Desktop.
Follow JSON logs formatted using jq. You can also pass jq options after the filename for filtering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| set -eo pipefail | |
| RED=$(echo -e '\033[0;1;31m') | |
| NORMAL=$(echo -e '\033[0m') | |
| if [[ $# -lt 1 ]]; then | |
| echo "usage: $0 <logfile> [jq-options...]">&2 | |
| exit 1 | |
| fi | |
| logfile=$1 | |
| shift | |
| tail -f "$logfile" | while read -r line; do | |
| echo "$line"|jq "$@" 2>/dev/null || echo "$RED$line$NORMAL" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment