Exemple #1
0
 def _build_msg(self, data):
     msg = []
     for i, (logname, (lines, unparsable)) in enumerate(sorted(data.items())):
         if not lines and not unparsable:
             # This should never happen - run_action filters such entries
             continue
         if self.group_by_source:
             lines = sorted(lines, key=lambda x: x[1]['source'].lower())
         if i > 0:
             msg += [''] * 3
         msg += underlined("Logstapo results for '{}'".format(logname))
         msg.append('')
         if unparsable:
             msg += underlined('Unparsable lines', '~')
             msg += unparsable
         if unparsable and lines:
             msg.append('')
         if lines:
             msg += underlined('Unusual lines', '-')
             msg += [x[0] for x in lines]
     return '\n'.join(msg)
Exemple #2
0
 def _build_msg(self, data):
     msg = []
     for i, (logname, (lines,
                       unparsable)) in enumerate(sorted(data.items())):
         if not lines and not unparsable:
             # This should never happen - run_action filters such entries
             continue
         if self.group_by_source:
             lines = sorted(lines, key=lambda x: x[1]['source'].lower())
         if i > 0:
             msg += [''] * 3
         msg += underlined("Logstapo results for '{}'".format(logname))
         msg.append('')
         if unparsable:
             msg += underlined('Unparsable lines', '~')
             msg += unparsable
         if unparsable and lines:
             msg.append('')
         if lines:
             msg += underlined('Unusual lines', '-')
             msg += [x[0] for x in lines]
     return '\n'.join(msg)
Exemple #3
0
def test_underlines(text, chars, expected):
    assert util.underlined(text, chars) == [text, expected]