Commit d4e06a41 authored by Vincent Pelletier's avatar Vincent Pelletier

Add support for parsing from stdin.

Document stdin & stdout capabilities in README.
parent 552d017e
...@@ -81,11 +81,15 @@ configuration (see `--logformat` argument documentation). ...@@ -81,11 +81,15 @@ configuration (see `--logformat` argument documentation).
Input files may be provided gzip'ed. Input files may be provided gzip'ed.
Input filename "-" is understood as stdin.
Output Output
------ ------
The output is HTML + CSS + JS, so you need a web browser to read it. The output is HTML + CSS + JS, so you need a web browser to read it.
Output filename "-" is understood as stdout.
Usage Usage
===== =====
......
...@@ -974,13 +974,16 @@ def main(): ...@@ -974,13 +974,16 @@ def main():
for fileno, filename in enumerate(infile_list, 1): for fileno, filename in enumerate(infile_list, 1):
print >> sys.stderr, 'Processing %s [%i/%i]' % ( print >> sys.stderr, 'Processing %s [%i/%i]' % (
filename, fileno, file_count) filename, fileno, file_count)
logfile = gzip.open(filename) if filename == '-':
try: logfile = sys.stdin
logfile.readline()
except IOError:
logfile = open(filename)
else: else:
logfile.seek(0) logfile = gzip.open(filename)
try:
logfile.readline()
except IOError:
logfile = open(filename)
else:
logfile.seek(0)
lineno = 0 lineno = 0
for lineno, line in enumerate(logfile, 1): for lineno, line in enumerate(logfile, 1):
if lineno % 5000 == 0: if lineno % 5000 == 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment