Commit 64b6e3ec authored by ale's avatar ale

remove ugly "name" class attribute

parent 4ade40d6
......@@ -15,8 +15,8 @@ def _parse_tag(tag):
_parser_registry = {}
def register_parser(class_):
_parser_registry[class_.name] = class_
def register_parser(name, class_):
_parser_registry[name] = class_
def get_parser(name, **args):
return _parser_registry[name](**args)
......@@ -56,21 +56,17 @@ class SyslogIsoParser(SyslogParserBase):
"""
name = 'iso'
def parse_date(self, line):
_stamp, _msg = line.split(' ', 1)
stamp = utils.parse_iso8601_date(_stamp)
return stamp, _msg
register_parser(SyslogIsoParser)
register_parser('iso', SyslogIsoParser)
class SyslogParser(SyslogParserBase):
"""Standard syslog format parser."""
name = 'standard'
def __init__(self, tz=None):
self.tz = tz # ignored for now
self.year = time.gmtime().tm_year
......@@ -84,13 +80,11 @@ class SyslogParser(SyslogParserBase):
stamp_tuple.tm_yday, -1)
return time.mktime(fixed_tuple), msg
register_parser(SyslogParser)
register_parser('standard', SyslogParser)
class SyslogDumbParser(SyslogParser):
name = 'dumb'
def __call__(self, line):
stamp, rest = self.parse_date(line)
host, tag, msg = rest.split(' ', 2)
......@@ -101,4 +95,4 @@ class SyslogDumbParser(SyslogParser):
info['pid'] = pid
return info
register_parser(SyslogDumbParser)
register_parser('dumb', SyslogDumbParser)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment