]> git.ipfire.org Git - nitsi.git/blobdiff - nitsi
Log all messages to a recipe with the name of the corresponding test
[nitsi.git] / nitsi
diff --git a/nitsi b/nitsi
old mode 100644 (file)
new mode 100755 (executable)
index 3c88b6a..d107a34
--- a/nitsi
+++ b/nitsi
@@ -1,6 +1,23 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from test import test
+import logging
+
+logger = logging.getLogger("nitsi")
+logger.setLevel(logging.DEBUG)
+# create file handler which logs even debug messages
+fh = logging.FileHandler('nitsi.log')
+fh.setLevel(logging.DEBUG)
+# create console handler with a higher log level
+ch = logging.StreamHandler()
+ch.setLevel(logging.DEBUG)
+
+formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+fh.setFormatter(formatter)
+ch.setFormatter(formatter)
+# add the handlers to the logger
+logger.addHandler(fh)
+logger.addHandler(ch)
 
 if __name__ == "__main__":
     import argparse