]>
gitweb.michael.orlitzky.com - djbdns-logparse.git/blob - bin/djbdns-logparse
7808fbd99a5042a9adc31828933949325561585e
3 Convert tinydns and dnscache logs to human-readable form
5 from argparse
import ArgumentParser
, FileType
6 from djbdns
.io
import parse_logfile
8 # Create an argument parser using the file's docsctring as its
10 parser
= ArgumentParser(description
= __doc__
)
12 # Parse zero or more positional arguments into a list of
13 # "logfiles". If none are given, read from stdin instead.
15 parser
.add_argument("logfiles",
20 help="djbdns logfile to process (default: stdin)")
22 # Warning: argparse automatically opens its file arguments here,
23 # and they only get closed when the program terminates. There's no
24 # real benefit to closing them one-at-a-time after calling
25 # parse_logfile(), because the "scarce" resource of open file
26 # descriptors gets consumed immediately, before any processing has
27 # happened. In other words, if you're going to run out of file
28 # descriptors, it's going to happen right now.
30 # So anyway, don't run this on several million logfiles.
31 args
= parser
.parse_args()
32 for f
in args
.logfiles
: