add parser-specific docs & rewrite sudo parser for journald
[logparse.git] / logparse / formatting.py
index 8528e1b262413bc00dd477b62b7a8298ff7da47b..624d66cf588a366ee375c5a19845b0f9e6f632a9 100644 (file)
@@ -2,9 +2,10 @@
 
 """   
 This file contains global functions for formatting and printing data. This file
-should be imported into individual log-parsing scripts located in logs/*. Data
-is formatted in HTML or plaintext. Writing to disk and/or emailng data is left
-to interface.py.
+should be imported into individual log-parsing scripts located in the default
+logparse.parsers module or in the user-supplied parsers directory. Data is
+formatted in HTML or plaintext. Writing to disk and/or emailng data is left to
+interface.py.
 """
 
 import os
@@ -151,6 +152,9 @@ class PlaintextOutput(Output):
         This should be run by interface.py after every instance of parse_log().
         """
 
+        if section == None:
+            logger.warning("Received null section")
+            return
         self.append(PlaintextBox(
             content=section.title, double=False,
             fullwidth=False, vpadding=0, hpadding=" ").draw())
@@ -279,6 +283,9 @@ class HtmlOutput(Output):
         instance of parse_log().
         """
 
+        if section == None:
+            logger.warning("Received null section")
+            return
         self.append(opentag('div', 1, section.title, 'section'))
         self.append(self._gen_title(section.title))
         if section.period and section.period.unique: