diff --git a/specs/master/cluster-init/files/host_provider/src/capacity_tracking_db.py b/specs/master/cluster-init/files/host_provider/src/capacity_tracking_db.py index 782c3cf..6120016 100644 --- a/specs/master/cluster-init/files/host_provider/src/capacity_tracking_db.py +++ b/specs/master/cluster-init/files/host_provider/src/capacity_tracking_db.py @@ -2,8 +2,6 @@ import os import calendar from util import JsonStore, init_logging -logger = init_logging() - class CapacityTrackingDb: @@ -12,6 +10,9 @@ class CapacityTrackingDb: self.cluster_name = cluster_name self.clock = clock self.limits_timeout = limits_timeout + # initialize in constructor so that cyclecloud_provider can initialize this + # with the proper log_level. In tests, this will use the default. + self.logger = init_logging() default_dir = os.getenv('HF_WORKDIR', '/var/tmp') self.db_dir = config.get('symphony.hostfactory.db_path', default_dir) diff --git a/specs/master/cluster-init/files/host_provider/src/util.py b/specs/master/cluster-init/files/host_provider/src/util.py index dd16e42..579be65 100644 --- a/specs/master/cluster-init/files/host_provider/src/util.py +++ b/specs/master/cluster-init/files/host_provider/src/util.py @@ -30,6 +30,16 @@ def init_logging(loglevel=logging.INFO, logfile=None): try: import jetpack jetpack.util.setup_logging() + root_logger = logging.getLogger() + filtered_handlers = [] + for handler in root_logger.handlers: + if hasattr(handler, "baseFilename"): + bfn = getattr(handler, "baseFilename") + if bfn and bfn.endswith("jetpack.log"): + continue + filtered_handlers.append(handler) + + root_logger.handlers = filtered_handlers for handler in logging.getLogger().handlers: handler.setLevel(logging.ERROR) except ImportError: