Commits

Marius Gedminas  committed 2c8f6aa

Interpolate log messages early to avoid incorrect output.

  • Participants
  • Parent commits 30575d0

Comments (0)

Files changed (2)

File dozer/logview.py

             exc_type, exc_value, exc_tb = record.exc_info
             record.exc_traceback = traceback.format_list(
                 traceback.extract_tb(exc_tb))
+        # Make sure we interpolate the message early.  Consider this code:
+        #    a_list = [1, 2, 3]
+        #    log.debug('a_list = %r', a_list)
+        #    del a_list[:]
+        # if we call getMessage() only when we're rendering all the messages
+        # at the end of request processing, we will see `a_list = []` instead
+        # of `a_list = [1, 2, 3]`
+        record.full_message = record.getMessage()
 
     def pop_events(self, thread_id):
         """Return all the events logged for particular thread"""

File dozer/templates/logbar.mako

                 <td style="background-color: ${bgcolor};">${event.name}</td>
                 <td style="background-color: ${bgcolor};">\
                     <%
-                        # XXX this is too late to call getMessage.  Example:
-                        #    a_list = [1, 2, 3]
-                        #    log.debug('a_list = %r', a_list)
-                        #    del a_list[:]
-                        # we will see `a_list = []` instead of `a_list = [1, 2, 3]`
-                        msg = event.getMessage()
+                        msg = event.full_message
                         length_limit = 130
                         keep_last = 70
                         if len(msg) > length_limit: