diff -r ef01c4639689 -r 952ee07efd7a pvl/syslog/parser.py --- a/pvl/syslog/parser.py Thu Jan 10 17:50:10 2013 +0200 +++ b/pvl/syslog/parser.py Thu Jan 10 17:51:53 2013 +0200 @@ -119,12 +119,13 @@ + r"(?P(?P(?P[^:\]]+)(?:\[(?P\d+)\])?: )?(?P.*))\n?" ) - def __init__ (self, raw=False) : + def __init__ (self, raw=False, facility=None) : """ Using given underlying line source. """ self.raw = raw + self.facility = facility def parse_pri (self, match) : """ @@ -132,10 +133,10 @@ """ pri = match.group('pri') - facility = match.group('facility') + facility = match.group('facility') or self.facility severity = match.group('severity') - if pri.isdigit() : + if pri and pri.isdigit() : pri = int(pri) facility, severity = divmod(pri, 8) @@ -182,9 +183,6 @@ # ignore whitespace line = line.strip() - # debug - log.debug("%s", line) - # timestamp? if self.raw : # from defaults @@ -214,8 +212,7 @@ ) # facility/severity prefix? - if match.group('pri') : - item.update(self.parse_pri(match)) + item.update(self.parse_pri(match)) return item @@ -227,6 +224,8 @@ for line in lines : item = self.parse(line) + log.debug("%s", item) + if item : yield item