-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding warning counter to analyzers.
- Loading branch information
kschmader
committed
Jul 3, 2024
1 parent
b1618b8
commit 45dbc01
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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""" | ||
) |