def main():
""" Main entry-point when running on the command-line"""
import argparse
parser = argparse.ArgumentParser(description='Chrome trace parser.',
prog='trace-parser')
parser.add_argument('-v', '--verbose', action='count',
help="Increase verbosity (specify multiple times for more)" \
". -vvvv for full debug output.")
parser.add_argument('-l', '--logfile', help="File name for the mozilla log.")
parser.add_argument('-s', '--start',
help="Start Time in UTC with microseconds YYYY-MM-DD HH:MM:SS.xxxxxx.")
parser.add_argument('-o', '--out', help="Output requests json file.")
options, _ = parser.parse_known_args()
# Set up logging
log_level = logging.CRITICAL
if options.verbose == 1:
log_level = logging.ERROR
elif options.verbose == 2:
log_level = logging.WARNING
elif options.verbose == 3:
log_level = logging.INFO
elif options.verbose >= 4:
log_level = logging.DEBUG
logging.basicConfig(
level=log_level, format="%(asctime)s.%(msecs)03d - %(message)s", datefmt="%H:%M:%S")
if not options.logfile or not options.start:
parser.error("Input devtools file or start time is not specified.")
parser = FirefoxLogParser()
requests = parser.process_logs(options.logfile, options.start)
if options.out:
with open(options.out, 'w') as f_out:
json.dump(requests, f_out, indent=4)
评论列表
文章目录