-
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 analyzer * Fixing formatting * Fixing formatting frfr :x * Fixing formatting yet again because @lassour keeps messing it up. * Finally actually fixing it --------- Co-authored-by: kschmader <[email protected]>
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
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
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,20 @@ | ||
from alogamous import analyzer | ||
|
||
|
||
class WarningAnalyzer(analyzer.Analyzer): | ||
def __init__(self): | ||
self.count = 0 | ||
|
||
def read_log_line(self, line): | ||
line_list = line.split(" ") | ||
# List should have format [date, timestamp, -, root, -, log message type, -, first word of message...] | ||
if line_list[5].lower() == "warning": | ||
self.count += 1 | ||
|
||
def report(self, out_stream): | ||
if self.count == 0: | ||
out_stream.write("\n" + "No Warnings were detected.") | ||
elif self.count == 1: | ||
out_stream.write("\n" + "1 Warning was detected.") | ||
else: | ||
out_stream.write("\n" + str(self.count) + " Warnings were detected.") |
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, warning_analyzer | ||
|
||
|
||
def test_warning_count(): | ||
in_stream = io.StringIO("""2024-06-20 11:00:18,185 - root - INFO - Kafka reading from start of day 2024-06-20 05:00:00+00:00 on topic internal from kafka.servers:9092 | ||
2024-06-20 11:00:19,328 - root - INFO - Kafka source starting for topic internal at current offset 7924032 end offset 7928950 on servers kafka.servers:9092 | ||
2024-06-20 11:00:22,329 - root - INFO - Kafka topic internal is caught up at offset 7928949 | ||
2024-06-20 11:00:22,329 - root - INFO - setting influx write rate to pre-market hours frequency | ||
2024-06-20 11:00:22,329 - root - INFO - Tracking service is caught up | ||
2024-06-20 11:40:43,527 - root - WARNING - instrument not found for sedol BYP321337 | ||
2024-06-20 11:40:43,527 - root - WARNING - instrument not found for sedol BYP321337 | ||
2024-06-20 17:25:08,029 - root - ERROR - Exception in message handler <bound method TrackingService.method of <app.tracking_service.TrackingService object at 0x7feba0d0>> TrackingService.on_order_change() missing 1 required positional argument: 'order_identifier'""") | ||
out_stream = io.StringIO() | ||
analyzer.analyze_log_stream([warning_analyzer.WarningAnalyzer()], in_stream, out_stream) | ||
assert out_stream.getvalue() == "\n2 Warnings were detected." |