Opened 11 years ago
Last modified 15 months ago
#11463 new enhancement
Strip markup from log messages
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-stable-1.6.x |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Jun Omae | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
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 plaintext
.
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.
-
trac/web/chrome.py
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 plaintext(exception_to_unicode(e))) 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.
Attachments (0)
Change History (8)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
Milestone: | next-stable-1.0.x → 1.0.3 |
---|
comment:3 by , 10 years ago
Small change in [5c1303b0/rjollos.git] that I'll save from committing until this ticket is implemented.
comment:4 by , 10 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:5 by , 10 years ago
Milestone: | 1.0.3 → next-stable-1.0.x |
---|---|
Owner: | removed |
Status: | assigned → new |
comment:6 by , 8 years ago
Milestone: | next-stable-1.0.x → next-stable-1.2.x |
---|
Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.
comment:7 by , 5 years ago
Milestone: | next-stable-1.2.x → next-stable-1.4.x |
---|
Good idea.
We expect
exception_to_unicode
convert an exception tounicode
instance. Also we often use it with logger. Therefore, I think we should useplaintext
function inexception_to_unicode
. It might be good to addexception_to_fragment
liketo_fragment
if needed.trac/util/text.py
trac/util/html.py