diff --git a/src/oidcmsg/logging.py b/src/oidcmsg/logging.py index c628e07..537b151 100644 --- a/src/oidcmsg/logging.py +++ b/src/oidcmsg/logging.py @@ -38,7 +38,7 @@ def configure_logging(debug: Optional[bool] = False, config_source = 'dictionary' elif filename is not None and os.path.exists(filename): with open(filename, "rt") as file: - config_dict = yaml.load(file) + config_dict = yaml.safe_load(file) config_source = 'file' else: config_dict = LOGGING_DEFAULT diff --git a/src/oidcmsg/time_util.py b/src/oidcmsg/time_util.py index b8fc9dc..8991bd7 100644 --- a/src/oidcmsg/time_util.py +++ b/src/oidcmsg/time_util.py @@ -20,6 +20,7 @@ """ import calendar +import logging import re import sys import time @@ -30,6 +31,8 @@ TIME_FORMAT_WITH_FRAGMENT = re.compile("^(\d{4,4}-\d{2,2}-\d{2,2}T\d{2,2}:\d{2,2}:\d{2,2})\.\d*Z$") +logger = logging.getLogger(__name__) + class TimeUtilError(Exception): pass @@ -287,7 +290,7 @@ def str_to_time(timestr, time_format=TIME_FORMAT): try: elem = TIME_FORMAT_WITH_FRAGMENT.match(timestr) except Exception as exc: - print >>sys.stderr, "Exception: %s on %s" % (exc, timestr) + logger.error("Exception: %s on %s" % (exc, timestr)) raise then = time.strptime(elem.groups()[0] + "Z", TIME_FORMAT)