From: Neil Smith Date: Tue, 8 Nov 2016 11:09:24 +0000 (+0000) Subject: Added formatting to the logger X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=38bf0effd8ed55869fa5abdef8ee0529e0ecd4c7;p=cipher-training.git Added formatting to the logger --- diff --git a/cipherbreak.py b/cipherbreak.py index 4f443c4..d5d3aa7 100644 --- a/cipherbreak.py +++ b/cipherbreak.py @@ -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 *