code: def watch_logfile(self, logfile_path):
          
          self._run_stats['logSource'] = logfile_path
          log_parser = LogParser()
  
          # For each new line in the logfile ...
          output_time = time.time() + WATCH_DISPLAY_REFRESH_SECONDS
          try:
              firstLine = True
              for line in self._tail_file(open(logfile_path),
                                          WATCH_INTERVAL_SECONDS):
                  if firstLine:
                      self._run_stats['timeRange']['start'] = get_line_time(line)
                  self._process_query(line, log_parser)
                  self._run_stats['timeRange']['end'] = get_line_time(line)
                  if time.time() >= output_time:
                      self._output_aggregated_report(sys.stderr)
                      output_time = time.time() + WATCH_DISPLAY_REFRESH_SECONDS
          except KeyboardInterrupt:
              sys.stderr.write("Interrupt received\n")
          finally:
              self._output_aggregated_report(sys.stdout)
  
          return 0
docs: Analyzes queries from the tail of a given log file