Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Path to the workflow directory
'''
formatter = log.handlers[0].formatter # gillespy2 log formatter
fh_is_needed = True
for handler in log.handlers:
if type(handler) is logging.StreamHandler:
handler.stream = sys.stderr # Reset the stream to stderr
handler.setLevel(logging.ERROR) # Only log error and critical logs to console
elif type(handler) is logging.FileHandler:
fh_is_needed = False # File Handler was already added to the log
# Add the file handler if it not in the log already
if fh_is_needed:
fh = logging.FileHandler(log_path) # initialize file handler
fh.setLevel(logging.WARNING) # log warning, error, and critical logs to file
fh.setFormatter(formatter) # add gillespy2 log formatter
log.addHandler(fh) # add file handler to log