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 re
from struct import pack
from time import strftime, gmtime