]> gitweb.michael.orlitzky.com - djbdns-logparse.git/blobdiff - bin/djbdns-logparse.py
bin/djbdns-logparse.py: use a variable to simplify a string template.
[djbdns-logparse.git] / bin / djbdns-logparse.py
index 2a7f6cab5bb4a1f4411d8de82c9ac88db46c0be4..8f30e1430cbfa1e8c6f9af11e398f5159d3ebd75 100755 (executable)
@@ -5,8 +5,6 @@ Convert tinydns and dnscache logs to human-readable form
 
 import re, typing
 from struct import pack
-from time import strftime, gmtime
-
 
 ## Regular expressions for matching tinydns/dnscache log lines. We
 ## compile these once here rather than within the corresponding
@@ -299,7 +297,11 @@ def handle_dnscache_log(line) -> typing.Optional[str]:
     elif event in ("tcpopen", "tcpclose"):
         decode_client(words, 0)
 
-    return f"{timestamp} {event} " + " ".join(words)
+    # Reconstitute "data" (i.e. everything after the timestamp and the
+    # event) from "words", which was originally obtained by splitting
+    # "data".
+    data = " ".join(words)
+    return f"{timestamp} {event} {data}"