From ddd36888faef61ae128ab3ef785ccf396806b216 Mon Sep 17 00:00:00 2001 From: CarlosCoelhoSL Date: Tue, 3 Dec 2024 11:18:32 +0000 Subject: [PATCH] adds logging to try except in collection.py --- digital_land/collection.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/digital_land/collection.py b/digital_land/collection.py index 1cadee45..6f814b40 100644 --- a/digital_land/collection.py +++ b/digital_land/collection.py @@ -16,6 +16,8 @@ # rename and change variable DEFAULT_COLLECTION_DIR = "./collection" +logger = logging.getLogger("__name__") + def isodate(s): return datetime.fromisoformat(s).strftime("%Y-%m-%d") @@ -116,6 +118,7 @@ def load( source: CSVStore, directory: str = DEFAULT_COLLECTION_DIR, after: datetime = None, + logging: bool = False, ): """ Rebuild or update resource.csv file from the log store. @@ -178,9 +181,10 @@ def load( # This occurs when there is a log for an endpoint, but the endpoint isn't in endpoint.csv/source.csv # This can happen when there is an unsuccessful attempt to add an endpoint and the log still exists # In this case we don't want to load this endpoint so skip - print( - f"Log for endpoint {endpoint} detected but endpoint is not in source.csv" - ) + if logging: + logging.error( + f"Log for endpoint {endpoint} detected but endpoint is not in source.csv" + ) continue new_entries[key] = {