general: improve logging during file processing in various modules

This commit is contained in:
karlicoss 2023-10-29 00:11:58 +01:00
parent bd27bd4c24
commit 278db3e2cd
4 changed files with 29 additions and 15 deletions

View file

@ -189,14 +189,16 @@ def _process_db(db: sqlite3.Connection):
def _messages() -> Iterator[Res[Message]]:
dbs = inputs()
for i, f in enumerate(dbs):
logger.info(f'processing {f} {i}/{len(dbs)}')
with sqlite_connection(f, immutable=True, row_factory='row') as db:
paths = inputs()
total = len(paths)
width = len(str(total))
for idx, path in enumerate(paths):
logger.info(f'processing [{idx:>{width}}/{total:>{width}}] {path}')
with sqlite_connection(path, immutable=True, row_factory='row') as db:
try:
yield from _process_db(db)
except Exception as e:
yield echain(RuntimeError(f'While processing {f}'), cause=e)
yield echain(RuntimeError(f'While processing {path}'), cause=e)
def messages() -> Iterator[Res[Message]]: