From 07e11fd599ee9bc72ba7d2d346f3e6a50501f418 Mon Sep 17 00:00:00 2001 From: Elizabeth Thompson Date: Thu, 11 Nov 2021 11:46:12 -0800 Subject: [PATCH] add logging to exception catch --- superset/tasks/cron_util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/superset/tasks/cron_util.py b/superset/tasks/cron_util.py index cf970a7c1c87f..d0a3f27ebec8e 100644 --- a/superset/tasks/cron_util.py +++ b/superset/tasks/cron_util.py @@ -18,11 +18,14 @@ from datetime import datetime, timedelta, timezone as dt_timezone from typing import Iterator +import logging from croniter import croniter from pytz import timezone as pytz_timezone, UnknownTimeZoneError from superset import app +logger = logging.getLogger(__name__) + def cron_schedule_window(cron: str, timezone: str) -> Iterator[datetime]: window_size = app.config["ALERT_REPORTS_CRON_WINDOW_SIZE"] @@ -33,6 +36,8 @@ def cron_schedule_window(cron: str, timezone: str) -> Iterator[datetime]: except UnknownTimeZoneError: # fallback to default timezone tz = pytz_timezone("UTC") + logger.warning( + "Timezone %s was invalid. Falling back to 'UTC'", timezone) utc = pytz_timezone("UTC") # convert the current time to the user's local time for comparison time_now = time_now.astimezone(tz)