fix: Log to the right places

pull/38/head
Hannah Ward 2017-12-28 12:21:26 +00:00
parent f1f4addfe3
commit 171bd70afc
No known key found for this signature in database
GPG Key ID: 6F3BAD60DE190290
2 changed files with 9 additions and 4 deletions

View File

@ -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)

View File

@ -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