Commit a2eb1ccd authored by Christopher Turner's avatar Christopher Turner

Add option to view log file at end of test

parent 1c3f94e9
......@@ -73,12 +73,12 @@ class RunTests(object):
summary = cls.get_summary()
self.console_logger.info(summary)
def setup_logging(logPath, fileName):
def setup_logging(logPath):
file_format_string = "%(asctime)s [%(levelname)-5s] [%(name)-10s] %(message)s"
console_format_string = "%(asctime)s [%(levelname)-5s] %(message)s"
logging.basicConfig(level=logging.DEBUG,
format=file_format_string,
filename=os.path.join(logPath, fileName))
filename=logPath)
logFormatter = logging.Formatter(console_format_string)
#set to log to console
......@@ -89,12 +89,25 @@ def setup_logging(logPath, fileName):
file_logger = logging.getLogger('filelog')
def view_log(log_file_path):
inputy = '.'
while inputy.strip('\n') not in ['y', 'n']:
print "\nView logfile: {} [y/n]".format(log_file_path)
inputy = raw_input()
if inputy.strip('\n') in ['y']:
f = open(log_file_path, 'r')
file_contents = f.read()
print (file_contents)
f.close()
def main():
timestr = time.strftime("%Y%m%d-%H%M%S")
log_file_name = "{}.log".format(timestr)
setup_logging('log', log_file_name)
log_file_name = os.path.join('log', "{}.log".format(timestr))
setup_logging(log_file_name)
rt = RunTests('config', '172.23.252.202', 8888) #pass in as parameter
rt.run_tests()
view_log(log_file_name)
if __name__ == '__main__':
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment