diff --git a/src/alogamous/log_line_parser.py b/src/alogamous/log_line_parser.py index 39dbcbf..5ef6c6e 100644 --- a/src/alogamous/log_line_parser.py +++ b/src/alogamous/log_line_parser.py @@ -1,6 +1,12 @@ from __future__ import annotations +class LineType: + HEADER_LINE = "header line" + LOG_LINE = "log line" + UNSTRUCTURED_LINE = "unstructured line" + + class LogLineParser: def __init__(self, header_line: str, expected_fields: list[str], seperator: str): self.header_line = header_line @@ -10,11 +16,11 @@ def __init__(self, header_line: str, expected_fields: list[str], seperator: str) def parse(self, line): if line == self.header_line: - return {"type": "header line", "line": line} + return {"type": LineType.HEADER_LINE, "line": line} if line.count(self.separator) == self.separator_count: - parsed_line = {"type": "log line"} + parsed_line = {"type": LineType.LOG_LINE} separated_line = line.split(self.separator) for index in range(len(self.expected_fields)): parsed_line[self.expected_fields[index]] = separated_line[index] return parsed_line - return {"type": "unstructured line", "line": line} + return {"type": LineType.UNSTRUCTURED_LINE, "line": line}