First of all, note that this example won't work if you're using a version of Python less than 2.6. If you fall into that category, you'll have to either upgrade your version, or simply pass over this section.
We're going to update our
LogProcessor script to report on the collection of HTTP response codes found within the logfile. We'll simply add an additional handler to process the parsed data.
logscan-e.pyas a base, create
logscan-f.pyand add the following additional import statement:
from collections import defaultdict
LogProcessorto also include HTTP status code information.
def split(self, line): """ Split a logfile. Initially, we just want size ...