diff options
author | Frederick Muriuki Muriithi | 2023-11-15 16:36:29 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-11-15 16:36:29 +0300 |
commit | 2bf17b88bca366f9ced851a6152e034f8e94f7ac (patch) | |
tree | be1aa43e43fbd1bb9d62fd1dcabfb83a8dd37912 | |
parent | c35a8d255bdf6a4f6f7ba555df9448e18513d95d (diff) | |
download | gn-uploader-2bf17b88bca366f9ced851a6152e034f8e94f7ac.tar.gz |
Log out DB errors even when handled
Log out any DB errors that occur to help with tracking and debugging
failures.
-rw-r--r-- | qc_app/db_utils.py | 2 | ||||
-rw-r--r-- | scripts/insert_data.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/qc_app/db_utils.py b/qc_app/db_utils.py index 7eca93a..a04c5e1 100644 --- a/qc_app/db_utils.py +++ b/qc_app/db_utils.py @@ -28,7 +28,7 @@ def database_connection(db_url: Optional[str] = None) -> Iterator[mdb.Connection yield connection connection.commit() except mdb.Error as _mdb_err: - logging.debug(traceback.format_exc()) + logging.error(traceback.format_exc()) connection.rollback() finally: connection.close() diff --git a/scripts/insert_data.py b/scripts/insert_data.py index fee2d26..45b6dd5 100644 --- a/scripts/insert_data.py +++ b/scripts/insert_data.py @@ -2,6 +2,7 @@ import sys import string import random +import logging import argparse from functools import reduce from typing import Tuple, Iterator @@ -15,6 +16,12 @@ from quality_control.file_utils import open_file from qc_app.db_utils import database_connection from qc_app.check_connections import check_db, check_redis +# Set up logging +stderr_handler = logging.StreamHandler(stream=sys.stderr) +root_logger = logging.getLogger() +root_logger.addHandler(stderr_handler) +root_logger.setLevel("WARNING") + def random_string(count: int = 10) -> str: """Generate a random, alphanumeric string.""" return "".join(random.choices( |