From f0dfc47636316ae1c4ec49e74df8148b8d08aacd Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Fri, 5 Aug 2022 09:41:12 +0200
Subject: [PATCH] privoxy-log-parser: Highlight the Crunch reason only once

Previously the "crunch reason" could also be highlighted when
the URL contained a matching string. The real crunch reason
only occurs once per line, so there's no need to continue
looking for it after it has been found once.

While at it, add a comment with an example log line.
---
 tools/privoxy-log-parser.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl
index 905767d2..b511931b 100755
--- a/tools/privoxy-log-parser.pl
+++ b/tools/privoxy-log-parser.pl
@@ -1460,7 +1460,8 @@ sub handle_loglevel_crunch($) {
 
     # Highlight crunch reason
     foreach my $reason (keys %reason_colours) {
-        $content =~ s@($reason)@$reason_colours{$reason}$1$h{'Standard'}@g;
+        # Crunch: Blocked: https://capture.condenastdigital.com/track?_o=cne&[...]&dim2=%7B%22adBlocked%[...]
+        $content =~ s@($reason)@$reason_colours{$reason}$1$h{'Standard'}@;
     }
 
     if ($content =~ m/\[too long, truncated\]$/) {
-- 
2.50.1