Commits

Ben Bangert  committed ea07040

Break up overly long messages

  • Participants
  • Parent commits e8fa65b

Comments (0)

Files changed (1)

File dozer/templates/logbar.mako

 %>
 
 <div style="width: 100%; position: absolute; top:0; left: 0; z-index: 200000; font-size:11px;">
-    <div style="width: 100%; background-color: #fff; border: 1px solid #999; padding: 3px;">
-        <a href="#" onclick="javascript:DLV.show_events();">View log events for this request</a>
+    <div style="width: 100%; background-color: #fff; border: 1px solid #999; padding: 3px; cursor: pointer;" onclick="javascript:DLV.show_events('DLVlogevents');">\
+        View log events for this request
     </div>
 <div id="DLVlogevents" style="display:none;">
     <table style="width: 100%; overflow: auto; background-color: #ddd;padding:2px;">
                 <td style="background-color: ${bgcolor};">${format_time(event)}</td>
                 <td style="background-color: ${bgcolor};">${event.levelname}</td>
                 <td style="background-color: ${bgcolor};">${event.name}</td>
-                <td style="background-color: ${bgcolor};">${event.getMessage() | h}</td>
+                <td style="background-color: ${bgcolor};">\
+                    <% 
+                        msg = event.getMessage()
+                        length_limit = 130
+                        if len(msg) > length_limit:
+                            use_split = True
+                            first = msg[:length_limit]
+                            last = msg[length_limit:]
+                        else:
+                            use_split = False
+                            parts = None
+                    %>
+                    % if use_split:
+                        <span style="cursor: pointer; text-decoration: underline;" onclick="javascript:DLV.show_span(${id(event)})">${first}</span>\
+<span style="display:inline;" id="${id(event)}_extra">...</span><span id="${id(event)}" style="display:none">${last}</span>
+                    % else:
+                        ${msg | h}\
+                    % endif
+                </td>
             </tr>
         % endfor
         <tr style="text-align: left; vertical-align: top; border-bottom: 1px solid #333; background-color: #eee; color: #222;">
 DLV.getEBI = function(id, d) {
     return (d || document).getElementById(id);
 };
-DLV.show_events = function(elem) {
-    elem = DLV.getEBI('DLVlogevents');
+DLV.show_events = function(name) {
+    var elem = DLV.getEBI(name);
     if (elem.style.display == 'block') {
         elem.style.display = 'none';
     } else {
     }
     return false;
 };
+DLV.show_span = function(name) {
+    var elem = DLV.getEBI(name);
+    if (elem.style.display == 'inline') {
+        elem.style.display = 'none';
+    } else {
+        elem.style.display = 'inline';
+    }
+    elem = DLV.getEBI(name+'_extra');
+    if (elem.style.display == 'inline') {
+        elem.style.display = 'none';
+    } else {
+        elem.style.display = 'inline';
+    }
+    return false;
+};
 </script>