Skip to content

Commit

Permalink
Merge branch 'reporting-with-newlines' into format-analyzer
Browse files Browse the repository at this point in the history
"merge conflict"
  • Loading branch information
kitrady committed Jul 31, 2024
2 parents 9d20151 + 13ae6c7 commit 726d1c9
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 167 deletions.
278 changes: 131 additions & 147 deletions data/test_output_file.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/alogamous/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ def analyze_log_stream(analyzers, in_stream, out_stream):
analyzer.read_log_line(line.rstrip())
for analyzer in analyzers:
analyzer.report(out_stream)
out_stream.write("\n>>>>>>>>>> a report has been reported <<<<<<<<<<\n")
out_stream.write("\n\n")
out_stream.write(">>>>>>>>>> a report has been reported <<<<<<<<<<\n\n")
5 changes: 2 additions & 3 deletions src/alogamous/flag_duplicate_log_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def read_log_line(self, line):
def report(self, out_stream):
if len(self.duplicateMessages) > 0:
out_stream.write("Duplicate Log Messages:\n")
for message in self.duplicateMessages:
out_stream.write(f"{message}\n")
out_stream.write("\n".join(self.duplicateMessages))
else:
out_stream.write("No duplicate log messages\n")
out_stream.write("No duplicate log messages")
2 changes: 1 addition & 1 deletion src/alogamous/format_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def read_log_line(self, line):

def report(self, out_stream):
if self.un_formated_lines:
out_stream.write("\nLines that do not conform to log format:\n- ")
out_stream.write("Lines that do not conform to log format:\n- ")
out_stream.write("\n- ".join(self.un_formated_lines))
else:
out_stream.write("All lines conform to log line format")
2 changes: 1 addition & 1 deletion src/alogamous/startup_header_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def read_log_line(self, line):
self.startup_block = False

def report(self, out_stream):
out_stream.write("\nLines that are part of the startup header(s):\n- ")
out_stream.write("Lines that are part of the startup header(s):\n- ")
out_stream.write("\n- ".join(self.startup_lines))
6 changes: 3 additions & 3 deletions src/alogamous/warning_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def read_log_line(self, line):

def report(self, out_stream):
if self.count == 0:
out_stream.write("\n" + "No Warnings were detected.")
out_stream.write("No Warnings were detected.")
elif self.count == 1:
out_stream.write("\n" + "1 Warning was detected.")
out_stream.write("1 Warning was detected.")
else:
out_stream.write("\n" + str(self.count) + " Warnings were detected.")
out_stream.write(str(self.count) + " Warnings were detected.")
5 changes: 1 addition & 4 deletions tests/analyze_log_stream_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ def test_analyze_log_stream():
out_stream = io.StringIO()

analyzer.analyze_log_stream([TestAnalyzer1(), TestAnalyzer2()], in_stream, out_stream)
assert (
out_stream.getvalue()
== "\n>>>>>>>>>> a report has been reported <<<<<<<<<<\n\n>>>>>>>>>> a report has been reported <<<<<<<<<<\n"
)
assert out_stream.getvalue() == "\n\n\n\n>>>>>>>>>> a report has been reported <<<<<<<<<<\n\n"
4 changes: 2 additions & 2 deletions tests/flag_duplicate_log_messages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_flag_duplicate_log_messages():
for line in in_stream:
flagger.read_log_line(line)
flagger.report(out_stream)
assert out_stream.getvalue() == """Duplicate Log Messages:\nlog message 1\n"""
assert out_stream.getvalue() == """Duplicate Log Messages:\nlog message 1"""


def test_flag_duplicate_log_messages_no_duplicates():
Expand All @@ -24,4 +24,4 @@ def test_flag_duplicate_log_messages_no_duplicates():
for line in in_stream:
flagger.read_log_line(line)
flagger.report(out_stream)
assert out_stream.getvalue() == """No duplicate log messages\n"""
assert out_stream.getvalue() == """No duplicate log messages"""
3 changes: 1 addition & 2 deletions tests/format_analyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def test_format_analyzer_with_bad_lines():
format_checker.report(out_stream)
assert (
out_stream.getvalue()
== """
Lines that do not conform to log format:
== """Lines that do not conform to log format:
- Hello I am a bad log line
- Hello I am a bad log line"""
)
Expand Down
3 changes: 1 addition & 2 deletions tests/startup_header_analyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def test_report():
startup_analyzer.report(out_stream)
assert (
out_stream.getvalue()
== """
Lines that are part of the startup header(s):
== """Lines that are part of the startup header(s):
- STARTING Tracking service
- Start time: 2024-06-20 09:00:00.001550+00:00
- Version: 2729a
Expand Down
2 changes: 1 addition & 1 deletion tests/warning_analyzer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test_warning_count():
for line in in_stream:
counter.read_log_line(line)
counter.report(out_stream)
assert out_stream.getvalue() == "\n2 Warnings were detected."
assert out_stream.getvalue() == "2 Warnings were detected."

0 comments on commit 726d1c9

Please sign in to comment.