From 171bd70afc647c4a07815df4fb95e09e6672ce9a Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Thu, 28 Dec 2017 12:21:26 +0000 Subject: [PATCH] fix: Log to the right places --- scripts/push_published_to_taxii.py | 11 ++++++++--- scripts/run-taxii-poll.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/push_published_to_taxii.py b/scripts/push_published_to_taxii.py index 6e5a9b5..6060083 100644 --- a/scripts/push_published_to_taxii.py +++ b/scripts/push_published_to_taxii.py @@ -10,9 +10,14 @@ from misp_stix_converter.converters import lint_roller import logging # Set up logger -logging.basicConfig(level=logging.INFO, format="'%(asctime)s - %(name)s - %(levelname)s - %(message)s')") log = logging.getLogger(__name__) +formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") +ch = logging.FileHandler("push.log") +ch.setFormatter(formatter) +log.addHandler(ch) +log.setLevel(logging.DEBUG) +log.info("Starting...") # Try to load in config if "OPENTAXII_CONFIG" in os.environ: config = yaml.load(open(os.environ["OPENTAXII_CONFIG"], "r")) @@ -97,5 +102,5 @@ while True: log.info("Pushed! (%s)", version) except Exception as ex: - log.fatal("COULD NOT PUSH") - log.exception(ex) + logging.fatal("COULD NOT PUSH") + logging.exception(ex) diff --git a/scripts/run-taxii-poll.py b/scripts/run-taxii-poll.py index 803e75b..4238834 100644 --- a/scripts/run-taxii-poll.py +++ b/scripts/run-taxii-poll.py @@ -17,7 +17,7 @@ args = parser.parse_args() # Set up a logger for logging's sake log = logging.getLogger(__name__) -logging.basicConfig(filename="poll.log", format="'%(asctime)s - %(name)s - %(levelname)s - %(message)s')") +logging.basicConfig(filename="poll.log", format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") log.setLevel(logging.DEBUG if args.verbose else logging.INFO) # If we want, print the output to stdout