Skip to content

Commit

Permalink
Adding warning counter to analyzers.
Browse files Browse the repository at this point in the history
  • Loading branch information
kschmader committed Jul 3, 2024
1 parent b1618b8 commit 45dbc01
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/alogamous/warning_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from alogamous import analyzer


class EchoAnalyzer(analyzer.Analyzer):
def __init__(self):
self.lines = []

def read_log_line(self, line):
self.lines.append(line)

def report(self, out_stream):
out_stream.write("\n".join(self.lines))
17 changes: 17 additions & 0 deletions tests/warning_analyzer_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import io

from alogamous import analyzer, echo_analyzer


def test_echo_lines():
in_stream = io.StringIO("""line1
line2
line3""")
out_stream = io.StringIO()
analyzer.analyze_log_stream([echo_analyzer.EchoAnalyzer()], in_stream, out_stream)
assert (
out_stream.getvalue()
== """line1
line2
line3"""
)

0 comments on commit 45dbc01

Please sign in to comment.