Added formatting to the logger
authorNeil Smith <neil.git@njae.me.uk>
Tue, 8 Nov 2016 11:09:24 +0000 (11:09 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Tue, 8 Nov 2016 11:09:24 +0000 (11:09 +0000)
cipherbreak.py

index 4f443c419e8d27cfb8746d8f52a262cf7d19bff2..d5d3aa76422c6b0109ee91d55b482d87c66c97a0 100644 (file)
@@ -13,12 +13,23 @@ from multiprocessing import Pool
 
 import matplotlib.pyplot as plt
 
-logging.basicConfig(filename="cipher.log", level=logging.INFO)
-logger = logging.getLogger(__name__)
-# logger.setLevel(logging.WARNING)
+# logging.basicConfig(filename="cipher.log", level=logging.INFO)
+# logger = logging.getLogger(__name__)
+
+logger = logging.getLogger('cipherbreak')
+logger.setLevel(logging.WARNING)
 # logger.setLevel(logging.INFO)
 # logger.setLevel(logging.DEBUG)
 
+# create the logging file handler
+fh = logging.FileHandler("cipher.log")
+formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+fh.setFormatter(formatter)
+
+# add handler to logger object
+logger.addHandler(fh)
+
+
 from cipher import *
 from language_models import *