From 71a25b18755ea229be17ca01003a68471ff72760 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:46:11 +0200 Subject: logf: make urgency patterns configurable --- krebs/5pkgs/logf/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'krebs') diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix index b575c1879..d9eae0a4a 100644 --- a/krebs/5pkgs/logf/default.nix +++ b/krebs/5pkgs/logf/default.nix @@ -16,12 +16,15 @@ let "7" = 139; # debug "-" = 005; # undefined priority }; + default-urgent = pkgs.writeJSON "logf.default-urgent.json" [ + ]; in pkgs.writeDashBin "logf" '' - export LOGF_HOST_COLORS LOGF_PRIO_COLORS + export LOGF_HOST_COLORS LOGF_PRIO_COLORS LOGF_URGENT LOGF_HOST_COLORS=$(cat "''${LOGF_HOST_COLORS-${default-host-colors}}") LOGF_PRIO_COLORS=$(cat "''${LOGF_PRIO_COLORS-${default-prio-colors}}") + LOGF_URGENT=$(cat "''${LOGF_URGENT-${default-urgent}}") printf '%s\0' "$@" \ | ${pkgs.findutils}/bin/xargs -0 -P 0 -n 1 ${pkgs.writeDash "logf-remote" '' target=$1 @@ -44,6 +47,8 @@ pkgs.writeDashBin "logf" '' | ${pkgs.jq}/bin/jq -Rrf ${pkgs.writeJq "logf-filter.jq" '' (env.LOGF_HOST_COLORS | fromjson) as $host_colors | (env.LOGF_PRIO_COLORS | fromjson) as $prio_colors | + (env.LOGF_URGENT | fromjson | map("(\(.))") | join("|")) + as $urgent_regex | def when(c; f): if c then f else . end; @@ -89,8 +94,7 @@ pkgs.writeDashBin "logf" '' as $prio_c | .MESSAGE | sub("\r$"; "") - | agsub("\\btv@nomic\\b"; "\(.)\u0007" | col(fg(219); $prio_c)) - #| agsub("Start queue"; "\(.)\u0007" | col(fg(42); $prio_c)) + | agsub($urgent_regex; "\(.)\u0007" | col(fg(219); $prio_c)) | col($prio_c); try fromjson catch { -- cgit v1.2.3