Convert tinydns and dnscache logs to human-readable form
"""
-#
-# Reads log files from tinydns and/or dnscache and prints them out in
-# human-readable form. Logs can be supplied on stdin, or listed on the
-# command line:
-#
-# $ cat @*.s | djbdns-logparse
-# $ djbdns-logparse @*.s
-# $ tail -f current | djbdns-logparse
-#
-# Pipes each log file through tai64nlocal, which must be on your path.
-#
-# Acknowledgments:
-#
-# * The log format descriptions by Rob Mayoff were invaluable:
-# ** http://dqd.com/~mayoff/notes/djbdns/tinydns-log.html
-# ** http://dqd.com/~mayoff/notes/djbdns/dnscache-log.html
-#
-# * Faried Nawaz's dnscache log parser was the original inspiration:
-# ** http://www.hungry.com/~fn/dnscache-log.pl.txt
-#
-
-import sys, re
+import re
from struct import pack
from time import strftime, gmtime
from subprocess import Popen, PIPE
# Parse zero or more positional arguments into a list of
# "logfiles". If none are given, read from stdin instead.
+ from sys import stdin
parser.add_argument("logfiles",
metavar="LOGFILE",
type=FileType("r"),
nargs="*",
- default=[sys.stdin],
+ default=[stdin],
help="djbdns logfile to process (default: stdin)")
args = parser.parse_args()