mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
Moving away from using the root logger everywhere (#9099)
* Moving away from using the root logger everywhere * self.logger -> logger
This commit is contained in:
@@ -65,6 +65,7 @@ except ImportError:
|
||||
|
||||
|
||||
logging.getLogger("MARKDOWN").setLevel(logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
DTTM_ALIAS = "__timestamp"
|
||||
ADHOC_METRIC_EXPRESSION_TYPES = {"SIMPLE": "SIMPLE", "SQL": "SQL"}
|
||||
@@ -99,9 +100,9 @@ def flasher(msg, severity=None):
|
||||
flash(msg, severity)
|
||||
except RuntimeError:
|
||||
if severity == "danger":
|
||||
logging.error(msg)
|
||||
logger.error(msg)
|
||||
else:
|
||||
logging.info(msg)
|
||||
logger.info(msg)
|
||||
|
||||
|
||||
class _memoized:
|
||||
@@ -242,7 +243,7 @@ def parse_human_datetime(s):
|
||||
parsed_dttm = parsed_dttm.replace(hour=0, minute=0, second=0)
|
||||
dttm = dttm_from_timetuple(parsed_dttm.utctimetuple())
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
logger.exception(e)
|
||||
raise ValueError("Couldn't parse date string [{}]".format(s))
|
||||
return dttm
|
||||
|
||||
@@ -544,7 +545,7 @@ def validate_json(obj):
|
||||
try:
|
||||
json.loads(obj)
|
||||
except Exception as e:
|
||||
logging.error(f"JSON is not valid {e}")
|
||||
logger.error(f"JSON is not valid {e}")
|
||||
raise SupersetException("JSON is not valid")
|
||||
|
||||
|
||||
@@ -568,7 +569,7 @@ class timeout:
|
||||
self.error_message = error_message
|
||||
|
||||
def handle_timeout(self, signum, frame):
|
||||
logging.error("Process timed out")
|
||||
logger.error("Process timed out")
|
||||
raise SupersetTimeoutException(self.error_message)
|
||||
|
||||
def __enter__(self):
|
||||
@@ -576,15 +577,15 @@ class timeout:
|
||||
signal.signal(signal.SIGALRM, self.handle_timeout)
|
||||
signal.alarm(self.seconds)
|
||||
except ValueError as e:
|
||||
logging.warning("timeout can't be used in the current context")
|
||||
logging.exception(e)
|
||||
logger.warning("timeout can't be used in the current context")
|
||||
logger.exception(e)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
try:
|
||||
signal.alarm(0)
|
||||
except ValueError as e:
|
||||
logging.warning("timeout can't be used in the current context")
|
||||
logging.exception(e)
|
||||
logger.warning("timeout can't be used in the current context")
|
||||
logger.exception(e)
|
||||
|
||||
|
||||
def pessimistic_connection_handling(some_engine):
|
||||
@@ -640,7 +641,7 @@ def notify_user_about_perm_udate(granter, user, role, datasource, tpl_name, conf
|
||||
msg = render_template(
|
||||
tpl_name, granter=granter, user=user, role=role, datasource=datasource
|
||||
)
|
||||
logging.info(msg)
|
||||
logger.info(msg)
|
||||
subject = __(
|
||||
"[Superset] Access to the datasource %(name)s was granted",
|
||||
name=datasource.full_name,
|
||||
@@ -746,12 +747,12 @@ def send_MIME_email(e_from, e_to, mime_msg, config, dryrun=False):
|
||||
s.starttls()
|
||||
if SMTP_USER and SMTP_PASSWORD:
|
||||
s.login(SMTP_USER, SMTP_PASSWORD)
|
||||
logging.info("Sent an email to " + str(e_to))
|
||||
logger.info("Sent an email to " + str(e_to))
|
||||
s.sendmail(e_from, e_to, mime_msg.as_string())
|
||||
s.quit()
|
||||
else:
|
||||
logging.info("Dryrun enabled, email notification content is below:")
|
||||
logging.info(mime_msg.as_string())
|
||||
logger.info("Dryrun enabled, email notification content is below:")
|
||||
logger.info(mime_msg.as_string())
|
||||
|
||||
|
||||
def get_email_address_list(address_string: str) -> List[str]:
|
||||
@@ -924,7 +925,7 @@ def get_or_create_db(database_name, sqlalchemy_uri, *args, **kwargs):
|
||||
db.session.query(models.Database).filter_by(database_name=database_name).first()
|
||||
)
|
||||
if not database:
|
||||
logging.info(f"Creating database reference for {database_name}")
|
||||
logger.info(f"Creating database reference for {database_name}")
|
||||
database = models.Database(database_name=database_name, *args, **kwargs)
|
||||
db.session.add(database)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user