forked from TKCERT/mail-security-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.py
28 lines (21 loc) · 831 Bytes
/
logging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Reporting of test results
import csv
class DummyLogger:
"""/dev/null logger"""
def __init__(self):
pass
def log(self, test : str, testid : int, recipient : str, delivered : bool = True, code : int = 0, msg : str = ""):
pass
def close(self):
pass
class CSVLogger:
"""Logging of test results"""
def __init__(self, logfile):
self.csvfile = open(logfile, "w")
self.csv = csv.writer(self.csvfile)
self.csv.writerow(("Test Class", "Test ID", "Recipient", "Delivered", "Code", "Message"))
def log(self, test : str, testid: int, recipient : str, delivered : bool = True, code : int = 0, msg : str = ""):
"""Log result"""
self.csv.writerow((test, testid, recipient, delivered, code, msg))
def close(self):
self.csvfile.close()