From f4abb99c8506fa85440d3ed47e8c3c0b1f9fb928 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Tue, 8 Nov 2016 11:09:24 +0000 Subject: [PATCH] Added formatting to the logger --- cipherbreak.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 * -- 2.34.1