From 3cf59b3d539adf168e4bc4876475e34257948163 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 11 Feb 2022 10:07:20 +0000
Subject: [PATCH] Add flag to log lines that did not match anything

---
 parser.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/parser.go b/parser.go
index 102ff00..f798f9b 100644
--- a/parser.go
+++ b/parser.go
@@ -1,11 +1,15 @@
 package main
 
 import (
+	"flag"
 	"fmt"
+	"log"
 	"regexp"
 	"strconv"
 )
 
+var logUncaught = flag.Bool("log-uncaught", false, "dump log lines that did not match")
+
 // A delivery is when a message is sent somewhere from within a
 // specific Flow. Deliveries are uniquely identified by their relay
 // attribute (recipients are aggregated by relay). We only keep track
@@ -303,6 +307,8 @@ func (p *Parser) analyze(ts, host, program, message string) error {
 		}
 	}
 
-	//log.Printf("uncaught: %s %s %s", host, program, message)
+	if *logUncaught {
+		log.Printf("uncaught: %s %s", program, message)
+	}
 	return nil
 }
-- 
GitLab