diff --git a/.gitignore b/.gitignore index 4595a6c..267acd3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ temp/** .idea .idea/** - +poetry.lock diff --git a/pyproject.toml b/pyproject.toml index c0fdb13..bae8b37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.12" +tqdm = "^4.66.5" [build-system] diff --git a/src/app.py b/src/app.py index 821c4a3..12cffbe 100644 --- a/src/app.py +++ b/src/app.py @@ -2,6 +2,8 @@ import argparse import re from datetime import datetime import os +from tqdm import tqdm + parser = argparse.ArgumentParser(prog='java-logs-analyzer') parser.add_argument('-l', '--logs', help='Logs file') @@ -54,17 +56,10 @@ def _parse(line: str) -> (bool, str, str, str, str, str, str): with open(args.logs, 'r') as file: - read_len = 0 - last_percent = -1 - percent = 0 + progress = tqdm(total=file_len, unit='b', unit_scale=2) for line in file: l = line.strip() - read_len += len(line) - percent = round(read_len / file_len * 100, 2) - cur_percent = round(percent / 10, 0) - if last_percent != cur_percent: - print(f"{percent}%", end='\r') - last_percent = cur_percent + progress.update(len(line)) (is_parsed, year, month, day, hour, minute, second) = _parse(l) if is_parsed: if first_line is None: