]> gitweb.michael.orlitzky.com - djbdns-logparse.git/commitdiff
bin/djbdns-logparse.py: add docs for parse_logfile().
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 15 Sep 2022 13:46:16 +0000 (09:46 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 15 Sep 2022 13:46:16 +0000 (09:46 -0400)
bin/djbdns-logparse.py

index 5067116cce5acec4c12e7bbbf3f337314643dc65..95bc4e07758763fdab7af3bb1e40a7633bcf42a4 100755 (executable)
@@ -3,7 +3,7 @@
 Convert tinydns and dnscache logs to human-readable form
 """
 
 Convert tinydns and dnscache logs to human-readable form
 """
 
-import re
+import re, typing
 from struct import pack
 from time import strftime, gmtime
 from subprocess import Popen, PIPE
 from struct import pack
 from time import strftime, gmtime
 from subprocess import Popen, PIPE
@@ -247,7 +247,17 @@ def handle_tinydns_log(line : str, match: re.Match):
                % (code, ip, port, id, type, name))
 
 
                % (code, ip, port, id, type, name))
 
 
-def parse_logfile(file):
+def parse_logfile(file : typing.TextIO):
+    """
+    Process a single log ``file``.
+
+    Parameters
+    ----------
+
+    file : typing.TextIO
+        An open log file, or stdin.
+
+    """
     # Open pipe to tai64nlocal: we will write lines of our input (the
     # raw log file) to it, and read log lines with readable timestamps
     # from it.
     # Open pipe to tai64nlocal: we will write lines of our input (the
     # raw log file) to it, and read log lines with readable timestamps
     # from it.
@@ -290,7 +300,5 @@ def main():
         parse_logfile(f)
 
 
         parse_logfile(f)
 
 
-
-
 if __name__ == "__main__":
     main()
 if __name__ == "__main__":
     main()