From 7873ffb495d0a1ecaa7254de9829d956255010ba Mon Sep 17 00:00:00 2001 From: Oleh Anufriiev Date: Tue, 4 Nov 2014 17:52:35 +0200 Subject: [PATCH] Added separate log level for Rally debugging Default DEBUG log level produces a lot of output from off-site components, like OpenStack clients etc. This patch implements addition log level 'RALLYDEBUG' and cli/config options. Change-Id: I58f29c5c69e23de297404a33e4e416e6844de4a3 --- rally/benchmark/context/base.py | 2 +- rally/benchmark/context/images.py | 2 +- rally/benchmark/context/keypair.py | 2 +- .../benchmark/context/quotas/cinder_quotas.py | 2 +- .../context/quotas/designate_quotas.py | 2 +- .../context/quotas/neutron_quotas.py | 2 +- rally/benchmark/context/quotas/nova_quotas.py | 2 +- rally/benchmark/context/quotas/quotas.py | 2 +- rally/benchmark/context/roles.py | 2 +- .../context/sahara/sahara_cluster.py | 2 +- rally/benchmark/context/sahara/sahara_edp.py | 2 +- .../benchmark/context/sahara/sahara_image.py | 2 +- rally/benchmark/context/secgroup.py | 2 +- rally/benchmark/context/tempest.py | 2 +- rally/benchmark/context/users.py | 2 +- rally/benchmark/context/volumes.py | 2 +- rally/benchmark/engine.py | 2 +- rally/benchmark/runners/base.py | 2 +- rally/benchmark/runners/constant.py | 2 +- rally/benchmark/runners/rps.py | 2 +- rally/benchmark/scenarios/neutron/utils.py | 2 +- rally/benchmark/scenarios/nova/servers.py | 2 +- rally/benchmark/scenarios/sahara/clusters.py | 2 +- rally/benchmark/scenarios/sahara/jobs.py | 2 +- rally/benchmark/scenarios/sahara/utils.py | 2 +- rally/broker.py | 2 +- rally/cmd/api.py | 2 +- rally/cmd/cliutils.py | 2 +- rally/deploy/engine.py | 2 +- rally/deploy/engines/devstack.py | 2 +- rally/deploy/engines/lxc.py | 2 +- rally/deploy/fuel/fuelclient.py | 2 +- rally/deploy/serverprovider/providers/lxc.py | 2 +- .../serverprovider/providers/openstack.py | 2 +- rally/exceptions.py | 2 +- rally/log.py | 57 +++++++++++++++++++ rally/orchestrator/api.py | 2 +- rally/sshutils.py | 2 +- rally/utils.py | 2 +- .../verification/verifiers/tempest/config.py | 2 +- 40 files changed, 96 insertions(+), 39 deletions(-) create mode 100644 rally/log.py diff --git a/rally/benchmark/context/base.py b/rally/benchmark/context/base.py index 02e4065b46..b4845d6a9f 100644 --- a/rally/benchmark/context/base.py +++ b/rally/benchmark/context/base.py @@ -19,7 +19,7 @@ import jsonschema import six from rally import exceptions -from rally.openstack.common import log as logging +from rally import log as logging from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/images.py b/rally/benchmark/context/images.py index 5df61a1955..bc3e313e7e 100644 --- a/rally/benchmark/context/images.py +++ b/rally/benchmark/context/images.py @@ -20,7 +20,7 @@ from rally.benchmark.scenarios import base as scenario_base from rally.benchmark.scenarios.glance import utils as glance_utils from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/context/keypair.py b/rally/benchmark/context/keypair.py index 203801469f..55546df8cc 100644 --- a/rally/benchmark/context/keypair.py +++ b/rally/benchmark/context/keypair.py @@ -18,7 +18,7 @@ import novaclient.exceptions from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager as resource_manager from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils diff --git a/rally/benchmark/context/quotas/cinder_quotas.py b/rally/benchmark/context/quotas/cinder_quotas.py index 734b4611fa..652a44478c 100644 --- a/rally/benchmark/context/quotas/cinder_quotas.py +++ b/rally/benchmark/context/quotas/cinder_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/quotas/designate_quotas.py b/rally/benchmark/context/quotas/designate_quotas.py index 933661fe7e..e18463a868 100644 --- a/rally/benchmark/context/quotas/designate_quotas.py +++ b/rally/benchmark/context/quotas/designate_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/quotas/neutron_quotas.py b/rally/benchmark/context/quotas/neutron_quotas.py index a768652073..fdc2a6a9d7 100644 --- a/rally/benchmark/context/quotas/neutron_quotas.py +++ b/rally/benchmark/context/quotas/neutron_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/quotas/nova_quotas.py b/rally/benchmark/context/quotas/nova_quotas.py index 539dcf8b42..ac1abbe723 100644 --- a/rally/benchmark/context/quotas/nova_quotas.py +++ b/rally/benchmark/context/quotas/nova_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/quotas/quotas.py b/rally/benchmark/context/quotas/quotas.py index 08c25e1acb..5907e12632 100644 --- a/rally/benchmark/context/quotas/quotas.py +++ b/rally/benchmark/context/quotas/quotas.py @@ -19,7 +19,7 @@ from rally.benchmark.context.quotas import designate_quotas from rally.benchmark.context.quotas import neutron_quotas from rally.benchmark.context.quotas import nova_quotas from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils diff --git a/rally/benchmark/context/roles.py b/rally/benchmark/context/roles.py index 6093c77abf..f9f9a73d43 100644 --- a/rally/benchmark/context/roles.py +++ b/rally/benchmark/context/roles.py @@ -16,7 +16,7 @@ from rally.benchmark.context import base from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/context/sahara/sahara_cluster.py b/rally/benchmark/context/sahara/sahara_cluster.py index b68eb139cf..c624725588 100644 --- a/rally/benchmark/context/sahara/sahara_cluster.py +++ b/rally/benchmark/context/sahara/sahara_cluster.py @@ -22,7 +22,7 @@ from rally.benchmark import types from rally.benchmark import utils as bench_utils from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/context/sahara/sahara_edp.py b/rally/benchmark/context/sahara/sahara_edp.py index 0c0afedabc..42569b64ff 100644 --- a/rally/benchmark/context/sahara/sahara_edp.py +++ b/rally/benchmark/context/sahara/sahara_edp.py @@ -19,7 +19,7 @@ from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager as resource_manager from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/context/sahara/sahara_image.py b/rally/benchmark/context/sahara/sahara_image.py index 16a647df66..0049fc23d0 100644 --- a/rally/benchmark/context/sahara/sahara_image.py +++ b/rally/benchmark/context/sahara/sahara_image.py @@ -17,7 +17,7 @@ from rally.benchmark.context.cleanup import manager as resource_manager from rally.benchmark.scenarios import base as scenarios_base from rally.benchmark.scenarios.glance import utils as glance_utils from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/context/secgroup.py b/rally/benchmark/context/secgroup.py index a33fa77581..8d77a87b51 100644 --- a/rally/benchmark/context/secgroup.py +++ b/rally/benchmark/context/secgroup.py @@ -15,7 +15,7 @@ from rally.benchmark.context import base from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils diff --git a/rally/benchmark/context/tempest.py b/rally/benchmark/context/tempest.py index c36645d085..899869f387 100644 --- a/rally/benchmark/context/tempest.py +++ b/rally/benchmark/context/tempest.py @@ -21,7 +21,7 @@ import tempfile from rally.benchmark.context import base from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import utils from rally.verification.verifiers.tempest import config from rally.verification.verifiers.tempest import tempest diff --git a/rally/benchmark/context/users.py b/rally/benchmark/context/users.py index e992a8fcfe..e2e4bacc22 100644 --- a/rally/benchmark/context/users.py +++ b/rally/benchmark/context/users.py @@ -24,8 +24,8 @@ from rally import broker from rally import consts from rally import exceptions from rally.i18n import _ +from rally import log as logging from rally.objects import endpoint -from rally.openstack.common import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/context/volumes.py b/rally/benchmark/context/volumes.py index e6be4f2fa8..112f30bd15 100644 --- a/rally/benchmark/context/volumes.py +++ b/rally/benchmark/context/volumes.py @@ -16,7 +16,7 @@ from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager as resource_manager from rally.benchmark.scenarios.cinder import utils as cinder_utils from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/engine.py b/rally/benchmark/engine.py index 5f87be8fd0..269b90ef11 100644 --- a/rally/benchmark/engine.py +++ b/rally/benchmark/engine.py @@ -29,8 +29,8 @@ from rally.benchmark.sla import base as base_sla from rally import consts from rally import exceptions from rally.i18n import _ +from rally import log as logging from rally.objects import endpoint -from rally.openstack.common import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/runners/base.py b/rally/benchmark/runners/base.py index 5958f8dec9..a52fb80bf5 100644 --- a/rally/benchmark/runners/base.py +++ b/rally/benchmark/runners/base.py @@ -25,7 +25,7 @@ from rally.benchmark import types from rally.benchmark import utils from rally import consts from rally import exceptions -from rally.openstack.common import log as logging +from rally import log as logging from rally import osclients from rally import utils as rutils diff --git a/rally/benchmark/runners/constant.py b/rally/benchmark/runners/constant.py index bacfd45e3f..5fe4e78615 100644 --- a/rally/benchmark/runners/constant.py +++ b/rally/benchmark/runners/constant.py @@ -20,7 +20,7 @@ import time from rally.benchmark.runners import base from rally.benchmark import utils from rally import consts -from rally.openstack.common import log as logging +from rally import log as logging from rally import utils as rutils diff --git a/rally/benchmark/runners/rps.py b/rally/benchmark/runners/rps.py index 6b6d121288..8130c877f4 100644 --- a/rally/benchmark/runners/rps.py +++ b/rally/benchmark/runners/rps.py @@ -20,7 +20,7 @@ import time from rally.benchmark.runners import base from rally import consts -from rally.openstack.common import log as logging +from rally import log as logging from rally import utils as rutils diff --git a/rally/benchmark/scenarios/neutron/utils.py b/rally/benchmark/scenarios/neutron/utils.py index db35c6be19..f504ccf89d 100644 --- a/rally/benchmark/scenarios/neutron/utils.py +++ b/rally/benchmark/scenarios/neutron/utils.py @@ -16,7 +16,7 @@ import netaddr from rally.benchmark.scenarios import base -from rally.openstack.common import log as logging +from rally import log as logging from rally.openstack.common import uuidutils as uid diff --git a/rally/benchmark/scenarios/nova/servers.py b/rally/benchmark/scenarios/nova/servers.py index 5fcc29e5cc..6cce681b6a 100644 --- a/rally/benchmark/scenarios/nova/servers.py +++ b/rally/benchmark/scenarios/nova/servers.py @@ -23,7 +23,7 @@ from rally.benchmark import types as types from rally.benchmark import validation from rally import consts from rally import exceptions as rally_exceptions -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/scenarios/sahara/clusters.py b/rally/benchmark/scenarios/sahara/clusters.py index 9fd06cdde7..58b3f2ddd6 100644 --- a/rally/benchmark/scenarios/sahara/clusters.py +++ b/rally/benchmark/scenarios/sahara/clusters.py @@ -18,7 +18,7 @@ from rally.benchmark.scenarios.sahara import utils from rally.benchmark import types from rally.benchmark import validation from rally import consts -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/scenarios/sahara/jobs.py b/rally/benchmark/scenarios/sahara/jobs.py index f05f42faa6..f92fd20399 100644 --- a/rally/benchmark/scenarios/sahara/jobs.py +++ b/rally/benchmark/scenarios/sahara/jobs.py @@ -17,7 +17,7 @@ from rally.benchmark.scenarios import base from rally.benchmark.scenarios.sahara import utils from rally.benchmark import validation from rally import consts -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/scenarios/sahara/utils.py b/rally/benchmark/scenarios/sahara/utils.py index 4580e10803..5764e0e281 100644 --- a/rally/benchmark/scenarios/sahara/utils.py +++ b/rally/benchmark/scenarios/sahara/utils.py @@ -19,7 +19,7 @@ from saharaclient.api import base as sahara_base from rally.benchmark.scenarios import base from rally.benchmark import utils as bench_utils from rally import exceptions -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/rally/broker.py b/rally/broker.py index 715844e468..7cbba6dfd8 100644 --- a/rally/broker.py +++ b/rally/broker.py @@ -20,7 +20,7 @@ import time from oslo.config import cfg from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging CONF = cfg.CONF diff --git a/rally/cmd/api.py b/rally/cmd/api.py index ce3649b8c3..2fe0a58766 100644 --- a/rally/cmd/api.py +++ b/rally/cmd/api.py @@ -24,7 +24,7 @@ from oslo.config import cfg from rally.aas.rest import app as rally_app from rally.i18n import _ -from rally.openstack.common import log +from rally import log CONF = cfg.CONF diff --git a/rally/cmd/cliutils.py b/rally/cmd/cliutils.py index 3b07d16eca..9a271c9aa2 100644 --- a/rally/cmd/cliutils.py +++ b/rally/cmd/cliutils.py @@ -23,9 +23,9 @@ import sys from oslo.config import cfg from rally.i18n import _ +from rally import log as logging from rally.openstack.common.apiclient import exceptions from rally.openstack.common import cliutils -from rally.openstack.common import log as logging from rally import utils from rally import version diff --git a/rally/deploy/engine.py b/rally/deploy/engine.py index 266e57a7ae..f5bab861d7 100644 --- a/rally/deploy/engine.py +++ b/rally/deploy/engine.py @@ -22,7 +22,7 @@ from rally import consts from rally.deploy.serverprovider import provider from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import utils diff --git a/rally/deploy/engines/devstack.py b/rally/deploy/engines/devstack.py index d5be4c9a0c..a19bad05ec 100644 --- a/rally/deploy/engines/devstack.py +++ b/rally/deploy/engines/devstack.py @@ -19,8 +19,8 @@ from rally import consts from rally.deploy import engine from rally.deploy.serverprovider import provider from rally.i18n import _ +from rally import log as logging from rally import objects -from rally.openstack.common import log as logging from rally import utils diff --git a/rally/deploy/engines/lxc.py b/rally/deploy/engines/lxc.py index 54554bc1ce..d115850761 100644 --- a/rally/deploy/engines/lxc.py +++ b/rally/deploy/engines/lxc.py @@ -22,8 +22,8 @@ from rally.deploy.serverprovider import provider from rally.deploy.serverprovider.providers import lxc from rally import exceptions from rally.i18n import _ +from rally import log as logging from rally import objects -from rally.openstack.common import log as logging from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/deploy/fuel/fuelclient.py b/rally/deploy/fuel/fuelclient.py index f38e5eafef..a65c45e5a6 100644 --- a/rally/deploy/fuel/fuelclient.py +++ b/rally/deploy/fuel/fuelclient.py @@ -19,7 +19,7 @@ import time import requests -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/deploy/serverprovider/providers/lxc.py b/rally/deploy/serverprovider/providers/lxc.py index 261cd4d7ec..1d892ce8af 100644 --- a/rally/deploy/serverprovider/providers/lxc.py +++ b/rally/deploy/serverprovider/providers/lxc.py @@ -23,7 +23,7 @@ import netaddr from rally.deploy.serverprovider import provider from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging from rally import utils diff --git a/rally/deploy/serverprovider/providers/openstack.py b/rally/deploy/serverprovider/providers/openstack.py index 8ddcb517fb..8ac5d3f886 100644 --- a/rally/deploy/serverprovider/providers/openstack.py +++ b/rally/deploy/serverprovider/providers/openstack.py @@ -23,8 +23,8 @@ from rally.benchmark import utils as benchmark_utils from rally.deploy.serverprovider import provider from rally import exceptions from rally.i18n import _ +from rally import log as logging from rally.objects import endpoint -from rally.openstack.common import log as logging from rally import osclients diff --git a/rally/exceptions.py b/rally/exceptions.py index 9aa5a75d9b..927c7dfdc4 100644 --- a/rally/exceptions.py +++ b/rally/exceptions.py @@ -19,7 +19,7 @@ import sys from oslo.config import cfg from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/log.py b/rally/log.py new file mode 100644 index 0000000000..e813314964 --- /dev/null +++ b/rally/log.py @@ -0,0 +1,57 @@ +# Copyright 2013: Mirantis Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging + +from oslo.config import cfg + +from rally.openstack.common import log as oslogging + + +common_cli_opts = [cfg.BoolOpt("rally-debug", + default=False, + help="Print debugging output only for Rally. " + "Off-site components stay quiet.")] + +CONF = cfg.CONF +CONF.register_cli_opts(common_cli_opts) + +logging.RDEBUG = logging.DEBUG + 1 +logging.addLevelName(logging.RDEBUG, "RALLYDEBUG") + + +def setup(product_name, version="unknown"): + dbg_color = oslogging.ColorHandler.LEVEL_COLORS[logging.DEBUG] + oslogging.ColorHandler.LEVEL_COLORS[logging.RDEBUG] = dbg_color + + oslogging.setup(product_name, version) + + if CONF.rally_debug: + oslogging.getLogger(None).logger.setLevel(logging.RDEBUG) + + +def getLogger(name="unknown", version="unknown"): + + if name not in oslogging._loggers: + oslogging._loggers[name] = RallyContextAdapter(logging.getLogger(name), + name, + version) + return oslogging._loggers[name] + + +class RallyContextAdapter(oslogging.ContextAdapter): + + def debug(self, msg, *args, **kwargs): + self.log(logging.RDEBUG, msg, *args, **kwargs) diff --git a/rally/orchestrator/api.py b/rally/orchestrator/api.py index 9bda37aa39..ed748795b8 100644 --- a/rally/orchestrator/api.py +++ b/rally/orchestrator/api.py @@ -19,8 +19,8 @@ from rally.benchmark import engine from rally import consts from rally import deploy from rally import exceptions +from rally import log as logging from rally import objects -from rally.openstack.common import log as logging from rally.verification.verifiers.tempest import tempest LOG = logging.getLogger(__name__) diff --git a/rally/sshutils.py b/rally/sshutils.py index 45d1921e77..2b6abda2cb 100644 --- a/rally/sshutils.py +++ b/rally/sshutils.py @@ -65,7 +65,7 @@ import time import paramiko from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging LOG = logging.getLogger(__name__) diff --git a/rally/utils.py b/rally/utils.py index a3e2099f68..5bc604f563 100644 --- a/rally/utils.py +++ b/rally/utils.py @@ -29,7 +29,7 @@ from sphinx.util import docstrings from rally import exceptions from rally.i18n import _ -from rally.openstack.common import log as logging +from rally import log as logging CONF = cfg.CONF LOG = logging.getLogger(__name__) diff --git a/rally/verification/verifiers/tempest/config.py b/rally/verification/verifiers/tempest/config.py index 1561d605d4..71e5b13104 100644 --- a/rally/verification/verifiers/tempest/config.py +++ b/rally/verification/verifiers/tempest/config.py @@ -15,7 +15,6 @@ import datetime import inspect -import logging import os import time import urlparse @@ -27,6 +26,7 @@ from six.moves import configparser from rally import db from rally import exceptions from rally.i18n import _ +from rally import log as logging from rally.objects import endpoint from rally import osclients