From a6031b01bfa3755438b83dd6b2608e8a69bee41c Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 10 Aug 2019 19:55:33 +0200 Subject: manage-fail-reasons: improved output --- bin/manage-fail-reasons | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'bin/manage-fail-reasons') diff --git a/bin/manage-fail-reasons b/bin/manage-fail-reasons index f110889..eaa7ff5 100755 --- a/bin/manage-fail-reasons +++ b/bin/manage-fail-reasons @@ -23,15 +23,15 @@ case "$1" in # shellcheck disable=SC2016 fail_reason_identifiers=$( { - printf 'SELECT `fail_reasons`.`id`,`fail_reasons`.`severity`,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")' + printf 'SELECT `fail_reasons`.`id`,name,`fail_reasons`.`severity`,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")' printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity` ASC, `fail_reasons`.id ASC' } | \ mysql_run_query ) printf '%s\n' "${fail_reason_identifiers}" | \ - while read -r reason_id severity identifier; do + while read -r reason_id name severity identifier; do ident=$(printf '%s' "${identifier}" | base64 -d -) - printf "%02s %03s %s\n" "$reason_id" "$severity" "$ident" + printf "%s %s %s %s\n" "$reason_id" "$name" "$severity" "$ident" done ;; 'check') @@ -53,13 +53,13 @@ case "$1" in esac fail_reason_identifiers=$( { - printf 'SELECT id,severity,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")' + printf 'SELECT id,severity,name,replace(to_base64(`fail_reasons`.`identifier`),"\\n","")' printf ' FROM `fail_reasons` ORDER BY `fail_reasons`.`severity` ASC, `fail_reasons`.id ASC' } | \ mysql_run_query ) printf '%s\n' "${fail_reason_identifiers}" | \ - while read -r id severity identifier; do + while read -r id severity name identifier; do if zgrep -qx "\s*$( printf '%s' "${identifier}" | \ base64 -d @@ -67,9 +67,10 @@ case "$1" in "$filelog"; then echo 'match' ident=$(printf '%s' "${identifier}" | base64 -d -) - printf "$id ($ident) matches with severity $severity\n" + printf "$name ($id, $ident) matches with severity $severity\n" fi done + zcat "$filelog" | tail -n 4 ;; *) >&2 printf 'unknown action "%s"\n' "$1" -- cgit v1.2.3-70-g09d2