log_formatter.py
changeset 80 a0662cff1d9d
parent 79 43ac75054d5c
child 86 645cf9c4441e
equal deleted inserted replaced
79:43ac75054d5c 80:a0662cff1d9d
     4 
     4 
     5 import re, xml.sax.saxutils
     5 import re, xml.sax.saxutils
     6 
     6 
     7 from log_line import LogTypes
     7 from log_line import LogTypes
     8 from log_formatter_pil import PILImageFormatter
     8 from log_formatter_pil import PILImageFormatter
       
     9 from log_formatter_rss import RSSFormatter
     9 
    10 
    10 class LogFormatter (object) :
    11 class LogFormatter (object) :
    11     """
    12     """
    12         Provides a method to format series of LogLines into various output formats, with varying themes.
    13         Provides a method to format series of LogLines into various output formats, with varying themes.
    13     """
    14     """
    81             See format_txt for information about arguments
    82             See format_txt for information about arguments
    82         """
    83         """
    83 
    84 
    84         abstract
    85         abstract
    85     
    86     
    86     def format_png (self, lines) :
    87     def format_png (self, lines, full_timestamps=False) :
    87         """
    88         """
    88             Format as a PNG image, returning the binary PNG data
    89             Format as a PNG image, returning the binary PNG data
    89         """
    90         """
       
    91 
       
    92         abstract
       
    93     
       
    94     def format_rss (self, lines, full_timestamps=False) :
       
    95         """
       
    96             Format as an XML RSS document
       
    97         """
       
    98         
       
    99         abstract
    90 
   100 
    91 class BaseHTMLFormatter (object) :
   101 class BaseHTMLFormatter (object) :
    92     """
   102     """
    93         Implements some HTML-formatting utils
   103         Implements some HTML-formatting utils
    94     """
   104     """
   109 
   119 
   110             return '<a href="%(url_link)s">%(url_html)s</a>' % dict(url_link=url_link, url_html=url_html)
   120             return '<a href="%(url_link)s">%(url_html)s</a>' % dict(url_link=url_link, url_html=url_html)
   111 
   121 
   112         return self.URL_REGEXP.sub(_encode_url, line)
   122         return self.URL_REGEXP.sub(_encode_url, line)
   113 
   123 
   114 class IrssiTextFormatter (PILImageFormatter, LogFormatter) :
   124 class IrssiTextFormatter (RSSFormatter, PILImageFormatter, LogFormatter) :
   115     """
   125     """
   116         Implements format_txt for irssi-style output
   126         Implements format_txt for irssi-style output
   117     """
   127     """
   118 
   128 
   119     # format definitions by type
   129     # format definitions by type