Skip to content

Commit eae29ab

Browse files
committed
add response status log
1 parent 7e3dffc commit eae29ab

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

functions-python/feed_sync_process_transitland/src/feed_processor_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ def check_url_status(url: str) -> bool:
1919
"""Check if a URL is reachable."""
2020
try:
2121
response = requests.head(url, timeout=10)
22-
return response.status_code < 400 or response.status_code == 403
22+
result = response.status_code < 400 or response.status_code == 403
23+
if not result:
24+
logging.error(
25+
"Url [%s] replied with status code: [%s]", url, response.status_code
26+
)
27+
return result
2328
except requests.RequestException:
24-
logging.warning(f"Failed to reach URL: {url}")
29+
logging.warning("Failed to reach URL: %s", url)
2530
return False
2631

2732

@@ -92,10 +97,10 @@ def create_new_feed(session: Session, stable_id: str, payload: FeedPayload) -> F
9297
)
9398
if location:
9499
new_feed.locations = [location]
95-
logging.debug(f"Added location for feed {new_feed.id}")
100+
logging.debug("Added location for feed %s", new_feed.id)
96101

97102
# Persist the new feed
98103
session.add(new_feed)
99104
session.flush()
100-
logging.info(f"Created new feed with ID: {new_feed.id}")
105+
logging.info("Created new feed with ID: %s", new_feed.id)
101106
return new_feed

0 commit comments

Comments
 (0)