diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-23 12:09:52 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-23 12:15:17 +0200 |
| commit | d23c5c00666fb83cd47a0136034164e8ef5a7df4 (patch) | |
| tree | 26662afb1b15bcd4abe0e19f6efc78fb9f574a01 /test/toolkit.py | |
| parent | test: add comments with sources (diff) | |
| download | aes-tools-d23c5c00666fb83cd47a0136034164e8ef5a7df4.tar.gz aes-tools-d23c5c00666fb83cd47a0136034164e8ef5a7df4.zip | |
test: proper logging setup
Diffstat (limited to 'test/toolkit.py')
| -rw-r--r-- | test/toolkit.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/toolkit.py b/test/toolkit.py index 4d8431d..7ef2b71 100644 --- a/test/toolkit.py +++ b/test/toolkit.py @@ -4,10 +4,28 @@ # Distributed under the MIT License. from collections.abc import Iterable +from contextlib import contextmanager from enum import Enum import logging import os.path import subprocess +import sys + + +@contextmanager +def setup_logging(verbose=False): + level = logging.DEBUG if verbose else logging.INFO + logging.basicConfig( + level=level, + datefmt="%Y-%m-%d %H:%M:%S%z", + # The 8 below is for "CRITICAL" + format="%(asctime)s | %(levelname)8s | %(message)s", + ) + try: + yield + except Exception as e: + logging.exception(e) + sys.exit(1) class Algorithm(Enum): |
