We now use the logging module
[nitsi.git] / nitsi
CommitLineData
1ed8ca9f 1#!/usr/bin/python3
f72f2f70
JS
2
3from test import test
1ed8ca9f
JS
4import logging
5
6logger = logging.getLogger("nitsi")
7logger.setLevel(logging.DEBUG)
8# create file handler which logs even debug messages
9fh = logging.FileHandler('nitsi.log')
10fh.setLevel(logging.DEBUG)
11# create console handler with a higher log level
12ch = logging.StreamHandler()
13ch.setLevel(logging.DEBUG)
14
15formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
16fh.setFormatter(formatter)
17ch.setFormatter(formatter)
18# add the handlers to the logger
19logger.addHandler(fh)
20logger.addHandler(ch)
f72f2f70
JS
21
22if __name__ == "__main__":
23 import argparse
24
25 parser = argparse.ArgumentParser()
26
27 parser.add_argument("-d", "--directory", dest="dir")
28
29 args = parser.parse_args()
30
31 currenttest = test(args.dir)
32 currenttest.read_settings()
33 currenttest.virtual_environ_setup()
34 currenttest.load_recipe()
35 try:
36 currenttest.virtual_environ_start()
37 currenttest.run_recipe()
38 except BaseException as e:
39 print(e)
40 finally:
41 currenttest.virtual_environ_stop()