mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
refactor: Rename bugdown_logger to markdown_logger.
This commit is part of series of commits aimed at renaming bugdown to markdown.
This commit is contained in:
@@ -211,7 +211,7 @@ def clear_state_for_testing() -> None:
|
|||||||
global LINK_REGEX
|
global LINK_REGEX
|
||||||
LINK_REGEX = None
|
LINK_REGEX = None
|
||||||
|
|
||||||
bugdown_logger = logging.getLogger()
|
markdown_logger = logging.getLogger()
|
||||||
|
|
||||||
def rewrite_local_links_to_relative(db_data: Optional[DbData], link: str) -> str:
|
def rewrite_local_links_to_relative(db_data: Optional[DbData], link: str) -> str:
|
||||||
"""If the link points to a local destination (e.g. #narrow/...),
|
"""If the link points to a local destination (e.g. #narrow/...),
|
||||||
@@ -397,8 +397,8 @@ def fetch_tweet_data(tweet_id: str) -> Optional[Dict[str, Any]]:
|
|||||||
tweet = timeout(3, api.GetStatus, tweet_id)
|
tweet = timeout(3, api.GetStatus, tweet_id)
|
||||||
res = tweet.AsDict()
|
res = tweet.AsDict()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
bugdown_logger.error('Unable to load twitter api, you may have the wrong '
|
markdown_logger.error('Unable to load twitter api, you may have the wrong '
|
||||||
'library installed, see https://github.com/zulip/zulip/issues/86')
|
'library installed, see https://github.com/zulip/zulip/issues/86')
|
||||||
return None
|
return None
|
||||||
except TimeoutExpired:
|
except TimeoutExpired:
|
||||||
# We'd like to try again later and not cache the bad result,
|
# We'd like to try again later and not cache the bad result,
|
||||||
@@ -423,7 +423,7 @@ def fetch_tweet_data(tweet_id: str) -> Optional[Dict[str, Any]]:
|
|||||||
# but for now it seems reasonable to log at error
|
# but for now it seems reasonable to log at error
|
||||||
# level (so that we get notified), but then cache the
|
# level (so that we get notified), but then cache the
|
||||||
# failure to proceed with our usual work
|
# failure to proceed with our usual work
|
||||||
bugdown_logger.exception("Unknown error fetching tweet data")
|
markdown_logger.exception("Unknown error fetching tweet data")
|
||||||
return None
|
return None
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -979,7 +979,7 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
|||||||
# We put this in its own try-except because it requires external
|
# We put this in its own try-except because it requires external
|
||||||
# connectivity. If Twitter flakes out, we don't want to not-render
|
# connectivity. If Twitter flakes out, we don't want to not-render
|
||||||
# the entire message; we just want to not show the Twitter preview.
|
# the entire message; we just want to not show the Twitter preview.
|
||||||
bugdown_logger.warning("Error building Twitter link", exc_info=True)
|
markdown_logger.warning("Error building Twitter link", exc_info=True)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_url_data(self, e: Element) -> Optional[Tuple[str, Optional[str]]]:
|
def get_url_data(self, e: Element) -> Optional[Tuple[str, Optional[str]]]:
|
||||||
@@ -2107,7 +2107,7 @@ def log_bugdown_error(msg: str) -> None:
|
|||||||
order to prevent AdminNotifyHandler from sending the sanitized
|
order to prevent AdminNotifyHandler from sending the sanitized
|
||||||
original markdown formatting into another Zulip message, which
|
original markdown formatting into another Zulip message, which
|
||||||
could cause an infinite exception loop."""
|
could cause an infinite exception loop."""
|
||||||
bugdown_logger.error(msg)
|
markdown_logger.error(msg)
|
||||||
|
|
||||||
def get_email_info(realm_id: int, emails: Set[str]) -> Dict[str, FullNameInfo]:
|
def get_email_info(realm_id: int, emails: Set[str]) -> Dict[str, FullNameInfo]:
|
||||||
if not emails:
|
if not emails:
|
||||||
@@ -2371,7 +2371,7 @@ def do_convert(content: str,
|
|||||||
# NOTE: Don't change this message without also changing the
|
# NOTE: Don't change this message without also changing the
|
||||||
# logic in logging_handlers.py or we can create recursive
|
# logic in logging_handlers.py or we can create recursive
|
||||||
# exceptions.
|
# exceptions.
|
||||||
bugdown_logger.exception(
|
markdown_logger.exception(
|
||||||
'Exception in Markdown parser; input (sanitized) was: %s\n (message %s)',
|
'Exception in Markdown parser; input (sanitized) was: %s\n (message %s)',
|
||||||
cleaned,
|
cleaned,
|
||||||
logging_message_id,
|
logging_message_id,
|
||||||
|
|||||||
@@ -824,7 +824,7 @@ class ZulipTestCase(TestCase):
|
|||||||
with \
|
with \
|
||||||
self.settings(ERROR_BOT=None), \
|
self.settings(ERROR_BOT=None), \
|
||||||
mock.patch('zerver.lib.markdown.timeout', side_effect=KeyError('foo')), \
|
mock.patch('zerver.lib.markdown.timeout', side_effect=KeyError('foo')), \
|
||||||
mock.patch('zerver.lib.markdown.bugdown_logger'):
|
mock.patch('zerver.lib.markdown.markdown_logger'):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
def create_default_device(self, user_profile: UserProfile,
|
def create_default_device(self, user_profile: UserProfile,
|
||||||
|
|||||||
@@ -2126,7 +2126,7 @@ class BugdownErrorTests(ZulipTestCase):
|
|||||||
msg = 'mock rendered message\n' * MAX_MESSAGE_LENGTH
|
msg = 'mock rendered message\n' * MAX_MESSAGE_LENGTH
|
||||||
|
|
||||||
with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \
|
with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \
|
||||||
mock.patch('zerver.lib.markdown.bugdown_logger'):
|
mock.patch('zerver.lib.markdown.markdown_logger'):
|
||||||
with self.assertRaises(MarkdownRenderingException):
|
with self.assertRaises(MarkdownRenderingException):
|
||||||
bugdown_convert(msg)
|
bugdown_convert(msg)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user