Strip markup from log messages
|Reported by:||Ryan J Ollos||Owned by:|
It was previously mentioned in comment:27:ticket:11189 and comment:3:ticket:11369 that it might be better to strip the markup from log messages to make them more readable. It occurred to me while reviewing the patch in #11462 that this might be as easy as wrapping the message in a call to
For example, currently we get a log message for the case of a
ConfigurationError (newlines have been added to make this more readable):
Trac[chrome] ERROR: Error during check of EMAIL_VIEW: ConfigurationError: Cannot find implementation(s) of the <tt>IPermissionPolicy</tt> interface named <tt>ReadonlyWikiPolicy</tt>. Please check that the Component is enabled or update the option <tt>[trac] permission_policies</tt> in trac.ini.
If the exception message is passed to
plaintext before being passed to the logger, we get:
Trac[chrome] ERROR: Error during check of EMAIL_VIEW: ConfigurationError: Cannot find implementation(s) of the IPermissionPolicy interface named ReadonlyWikiPolicy. Please check that the Component is enabled or update the option [trac] permission_policies in trac.ini.
diff --git a/trac/web/chrome.py b/trac/web/chrome.py index f627ae5..864d569 100644
a b class Chrome(Component): 866 866 # simply log the exception here, as we might already be rendering 867 867 # the error page 868 868 self.log.error("Error during check of EMAIL_VIEW: %s", 869 exception_to_unicode(e)) 869 )) 870 870 show_email_addresses = False 871 871 872 872 def pretty_dateinfo(date, format=None, dateonly=False):
To be investigated is whether the best approach is to wrap the exception message that is passed to the logger everywhere that the exceptions are trapped, or if there is a better approach.
Change History (7)
comment:5 by , 6 years ago
|Milestone:||1.0.3 → next-stable-1.0.x|
|Status:||assigned → new|