Commit 27688b11 authored by Tjerk Vreeken's avatar Tjerk Vreeken

Merge branch 'check-existing-loggers' into 'casadi3'

Check if root logger already has loggers

See merge request !87
parents 01550d14 b9042604
......@@ -50,7 +50,7 @@ def run_optimization_problem(optimization_problem_class, base_folder='..', log_l
logger.addHandler(handler)
# Add stream handler if it does not already exist.
if not any((isinstance(h, logging.StreamHandler) for h in logger.handlers)):
if not logger.hasHandlers() and not any((isinstance(h, logging.StreamHandler) for h in logger.handlers)):
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment