log_formatter.py
changeset 72 5ade0288f2ec
parent 69 1f182913b1f2
child 73 5a7188bf2894
--- a/log_formatter.py	Mon Feb 09 14:07:19 2009 +0200
+++ b/log_formatter.py	Mon Feb 09 22:17:10 2009 +0200
@@ -11,9 +11,16 @@
         Provides a method to format series of LogLines into various output formats, with varying themes.
     """
 
-    # the formatter's code name
+    # machine-readable name
     name = None
-    
+
+    # human-readable name
+    title = None
+
+    ## parameters
+    # use a fixed-width font for HTML output
+    html_fixedwidth = True
+
     def __init__ (self, tz, timestamp_fmt="%H:%M:%S") :
         """
             Initialize to format timestamps with the given timezone and timestamp
@@ -108,37 +115,35 @@
         # ...handle each line
         for line in lines :
             # using __TYPES
-            yield self._format_line_text(line, self.__FMT, full_timestamps)
+            yield line, self._format_line_text(line, self.__FMT, full_timestamps)
 
 class IrssiFormatter (IrssiTextFormatter, BaseHTMLFormatter) :
     """
         Implements plain black-and-white irssi-style formatting
     """
-
+    
+    # name
     name = 'irssi'
     title = "Irssi (plain)"
 
+    # parameters
+    html_fixedwidth = True
+
     def format_html (self, lines, full_timestamps=False) :
         """
-            Just uses format_txt, but wraps in <pre></pre>
+            Just uses format_txt, but processes links, etc
         """
         
-        # open pre
-        yield "<pre>"
-        
         # format using IrssiTextFormatter
-        for line in self.format_txt(lines, full_timestamps) :
+        for line, txt in self.format_txt(lines, full_timestamps) :
             # escape HTML
-            line = xml.sax.saxutils.escape(line)
+            html = xml.sax.saxutils.escape(txt)
 
             # process links
-            line = self._process_links(line)
+            html = self._process_links(html)
 
             # yield
-            yield line
-
-        # close pre
-        yield "</pre>"
+            yield line, html
 
 # define formatters by name
 FORMATTERS = {