Here are the examples of the python api parsers.LogParser taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
0
Example 1
Project: dex Source File: dex.py
def analyze_logfile_object(self, file_object):
"""Analyzes queries from a given log file"""
log_parser = LogParser()
if self._start_time is None:
self._start_time = datetime.now()
if self._timeout != 0:
self._end_time = self._start_time + timedelta(minutes=self._timeout)
else:
self._end_time = None
# For each line in the logfile ...
for line in file_object:
if self._end_time is not None and datetime.now() > self._end_time:
self._run_stats['timedOut'] = True
self._run_stats['timeoutInMinutes'] = self._timeout
break
self._process_query(line, log_parser)
return 0
0
Example 2
Project: dex Source File: dex.py
def watch_logfile(self, logfile_path):
"""Analyzes queries from the tail of a given log file"""
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