mirror of https://github.com/zulip/zulip.git
bugdown: Extract log_bugdown_error().
(It makes it easier to mock out the logging.)
This commit is contained in:
parent
c4dd3ba0d3
commit
152cebf33d
|
@ -1121,6 +1121,14 @@ current_message = None # type: Optional[Message]
|
|||
# threads themselves, as well.
|
||||
db_data = None # type: Dict[text_type, Any]
|
||||
|
||||
def log_bugdown_error(msg):
|
||||
# type: (str) -> None
|
||||
"""We use this unusual logging approach to log the bugdown error, in
|
||||
order to prevent AdminZulipHandler from sending the santized
|
||||
original markdown formatting into another Zulip message, which
|
||||
could cause an infinite exception loop."""
|
||||
logging.getLogger('').error(msg)
|
||||
|
||||
def do_convert(md, realm_domain=None, message=None):
|
||||
# type: (markdown.Markdown, Optional[text_type], Optional[Message]) -> Optional[text_type]
|
||||
"""Convert Markdown to HTML, with Zulip-specific settings and hacks."""
|
||||
|
@ -1160,7 +1168,7 @@ def do_convert(md, realm_domain=None, message=None):
|
|||
cleaned = _sanitize_for_log(md)
|
||||
|
||||
# Output error to log as well as sending a zulip and email
|
||||
logging.getLogger('').error('Exception in Markdown parser: %sInput (sanitized) was: %s'
|
||||
log_bugdown_error('Exception in Markdown parser: %sInput (sanitized) was: %s'
|
||||
% (traceback.format_exc(), cleaned))
|
||||
subject = "Markdown parser failure on %s" % (platform.node(),)
|
||||
if settings.ERROR_BOT is not None:
|
||||
|
|
Loading…
Reference in New Issue