change name of rally.common.log module

Copied `rally.common.log` to `rally.common.logging`
Marked `rally.common.log` as deprecated

Change-Id: Ia7926e5f8a716a8a5b74c0f46d9b797e4fe23ddc
Closes-Bug: #1521573
This commit is contained in:
Bo Chi 2015-12-06 23:59:16 -05:00
parent 8e374ae1c1
commit 79adee9c00
88 changed files with 393 additions and 371 deletions

View File

@ -138,7 +138,7 @@ Inherit a class for your plugin from the base *Context* class. Then, implement t
.. code-block:: python
from rally.task import context
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import osclients

View File

@ -24,7 +24,7 @@ import jinja2.meta
import jsonschema
from rally.common.i18n import _, _LI
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally import consts
from rally.deployment import engine as deploy_engine

View File

@ -30,7 +30,7 @@ import six
import sqlalchemy.exc
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import discover
from rally.common.plugin import info
from rally.common import version

View File

@ -32,7 +32,7 @@ from rally.cli import envutils
from rally.common import fileutils
from rally.common.i18n import _
from rally.common import junit
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions

View File

@ -17,7 +17,7 @@ import collections
import threading
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -13,260 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import functools
import logging
from rally.common.logging import * # noqa
from oslo_config import cfg
from oslo_log import handlers
from oslo_log import log as oslogging
from rally.common.i18n import _
DEBUG_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(DEBUG_OPTS)
oslogging.register_options(CONF)
logging.RDEBUG = logging.DEBUG + 1
logging.addLevelName(logging.RDEBUG, "RALLYDEBUG")
CRITICAL = logging.CRITICAL
DEBUG = logging.DEBUG
ERROR = logging.ERROR
FATAL = logging.FATAL
INFO = logging.INFO
NOTSET = logging.NOTSET
RDEBUG = logging.RDEBUG
WARN = logging.WARN
WARNING = logging.WARNING
def setup(product_name, version="unknown"):
dbg_color = handlers.ColorHandler.LEVEL_COLORS[logging.DEBUG]
handlers.ColorHandler.LEVEL_COLORS[logging.RDEBUG] = dbg_color
oslogging.setup(CONF, product_name, version)
if CONF.rally_debug:
oslogging.getLogger(
project=product_name).logger.setLevel(logging.RDEBUG)
class RallyContextAdapter(oslogging.KeywordArgumentAdapter):
def debug(self, msg, *args, **kwargs):
self.log(logging.RDEBUG, msg, *args, **kwargs)
def getLogger(name="unknown", version="unknown"):
if name not in oslogging._loggers:
oslogging._loggers[name] = RallyContextAdapter(logging.getLogger(name),
{"project": "rally",
"version": version})
return oslogging._loggers[name]
LOG = getLogger(__name__)
class ExceptionLogger(object):
"""Context that intercepts and logs exceptions.
Usage::
LOG = logging.getLogger(__name__)
...
def foobar():
with ExceptionLogger(LOG, "foobar warning") as e:
return house_of_raising_exception()
if e.exception:
raise e.exception # remove if not required
"""
def __init__(self, logger, warn=None):
self.logger = logger
self.warn = warn
self.exception = None
def __enter__(self):
return self
def __exit__(self, type_, value, traceback):
if value:
self.exception = value
if self.warn:
self.logger.warning(self.warn)
self.logger.debug(value)
if is_debug():
self.logger.exception(value)
return True
class CatcherHandler(logging.handlers.BufferingHandler):
def __init__(self):
logging.handlers.BufferingHandler.__init__(self, 0)
def shouldFlush(self):
return False
def emit(self, record):
self.buffer.append(record)
class LogCatcher(object):
"""Context manager that catches log messages.
User can make an assertion on their content or fetch them all.
Usage::
LOG = logging.getLogger(__name__)
...
def foobar():
with LogCatcher(LOG) as catcher_in_rye:
LOG.warning("Running Kids")
catcher_in_rye.assertInLogs("Running Kids")
"""
def __init__(self, logger):
self.logger = getattr(logger, "logger", logger)
self.handler = CatcherHandler()
def __enter__(self):
self.logger.addHandler(self.handler)
return self
def __exit__(self, type_, value, traceback):
self.logger.removeHandler(self.handler)
def assertInLogs(self, msg):
"""Assert that `msg' is a substring at least of one logged message.
:param msg: Substring to look for.
:return: Log messages where the `msg' was found.
Raises AssertionError if none.
"""
in_logs = [record.msg
for record in self.handler.buffer if msg in record.msg]
if not in_logs:
raise AssertionError("Expected `%s' is not in logs" % msg)
return in_logs
def fetchLogRecords(self):
"""Returns all logged Records."""
return self.handler.buffer
def fetchLogs(self):
"""Returns all logged messages."""
return [record.msg for record in self.handler.buffer]
def _log_wrapper(obj, log_function, msg, **kw):
"""A logging wrapper for any method of a class.
Class instances that use this decorator should have self.task or
self.deployment attribute. The wrapper produces logs messages both
before and after the method execution, in the following format
(example for tasks):
"Task <Task UUID> | Starting: <Logging message>"
[Method execution...]
"Task <Task UUID> | Completed: <Logging message>"
:param obj: task or deployment which must be attribute of "self"
:param log_function: Logging method to be used, e.g. LOG.info
:param msg: Text message (possibly parameterized) to be put to the log
:param **kw: Parameters for msg
"""
def decorator(f):
@functools.wraps(f)
def wrapper(self, *args, **kwargs):
params = {"msg": msg % kw, "obj_name": obj.title(),
"uuid": getattr(self, obj)["uuid"]}
log_function(_("%(obj_name)s %(uuid)s | Starting: %(msg)s") %
params)
result = f(self, *args, **kwargs)
log_function(_("%(obj_name)s %(uuid)s | Completed: %(msg)s") %
params)
return result
return wrapper
return decorator
def log_task_wrapper(log_function, msg, **kw):
return _log_wrapper("task", log_function, msg, **kw)
def log_deploy_wrapper(log_function, msg, **kw):
return _log_wrapper("deployment", log_function, msg, **kw)
def log_verification_wrapper(log_function, msg, **kw):
return _log_wrapper("verification", log_function, msg, **kw)
def log_deprecated(message, rally_version, log_function=None, once=False):
"""A wrapper marking a certain method as deprecated.
:param message: Message that describes why the method was deprecated
:param rally_version: version of Rally when the method was deprecated
:param log_function: Logging method to be used, e.g. LOG.info
:param once: Show only once (default is each)
"""
log_function = log_function or LOG.warning
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
if (not once) or (not getattr(f, "_warned_dep_method", False)):
log_function("'%(func)s' is deprecated in Rally v%(version)s: "
"%(msg)s" % {"msg": message,
"version": rally_version,
"func": f.__name__})
setattr(f, "_warned_dep_method", once)
return f(*args, **kwargs)
return wrapper
return decorator
def log_deprecated_args(message, rally_version, deprecated_args,
log_function=None, once=False):
"""A wrapper marking certain arguments as deprecated.
:param message: Message that describes why the arguments were deprecated
:param rally_version: version of Rally when the arguments were deprecated
:param deprecated_args: List of deprecated args.
:param log_function: Logging method to be used, e.g. LOG.info
:param once: Show only once (default is each)
"""
log_function = log_function or LOG.warning
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
if (not once) or (not getattr(f, "_warned_dep_args", False)):
deprecated = ", ".join([
"`%s'" % x for x in deprecated_args if x in kwargs])
if deprecated:
log_function(
"%(msg)s (args %(args)s deprecated in Rally "
"v%(version)s)" %
{"msg": message, "version": rally_version,
"args": deprecated})
setattr(f, "_warned_dep_args", once)
result = f(*args, **kwargs)
return result
return wrapper
return decorator
def is_debug():
return CONF.debug or CONF.rally_debug
import warnings
warnings.warn("rally.common.log is deprecated since Rally 0.1.2. "
"Please use rally.common.logging instead.")

273
rally/common/logging.py Normal file
View File

@ -0,0 +1,273 @@
# Copyright 2014: 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 functools
from oslo_config import cfg
from oslo_log import handlers
from oslo_log import log as oslogging
from rally.common.i18n import _
log = __import__("logging")
DEBUG_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(DEBUG_OPTS)
oslogging.register_options(CONF)
log.RDEBUG = log.DEBUG + 1
log.addLevelName(log.RDEBUG, "RALLYDEBUG")
CRITICAL = log.CRITICAL
DEBUG = log.DEBUG
ERROR = log.ERROR
FATAL = log.FATAL
INFO = log.INFO
NOTSET = log.NOTSET
RDEBUG = log.RDEBUG
WARN = log.WARN
WARNING = log.WARNING
def setup(product_name, version="unknown"):
dbg_color = handlers.ColorHandler.LEVEL_COLORS[log.DEBUG]
handlers.ColorHandler.LEVEL_COLORS[log.RDEBUG] = dbg_color
oslogging.setup(CONF, product_name, version)
if CONF.rally_debug:
oslogging.getLogger(
project=product_name).logger.setLevel(log.RDEBUG)
class RallyContextAdapter(oslogging.KeywordArgumentAdapter):
def debug(self, msg, *args, **kwargs):
self.log(log.RDEBUG, msg, *args, **kwargs)
def getLogger(name="unknown", version="unknown"):
if name not in oslogging._loggers:
oslogging._loggers[name] = RallyContextAdapter(log.getLogger(name),
{"project": "rally",
"version": version})
return oslogging._loggers[name]
LOG = getLogger(__name__)
class ExceptionLogger(object):
"""Context that intercepts and logs exceptions.
Usage::
LOG = logging.getLogger(__name__)
...
def foobar():
with ExceptionLogger(LOG, "foobar warning") as e:
return house_of_raising_exception()
if e.exception:
raise e.exception # remove if not required
"""
def __init__(self, logger, warn=None):
self.logger = logger
self.warn = warn
self.exception = None
def __enter__(self):
return self
def __exit__(self, type_, value, traceback):
if value:
self.exception = value
if self.warn:
self.logger.warning(self.warn)
self.logger.debug(value)
if is_debug():
self.logger.exception(value)
return True
class CatcherHandler(log.handlers.BufferingHandler):
def __init__(self):
log.handlers.BufferingHandler.__init__(self, 0)
def shouldFlush(self):
return False
def emit(self, record):
self.buffer.append(record)
class LogCatcher(object):
"""Context manager that catches log messages.
User can make an assertion on their content or fetch them all.
Usage::
LOG = logging.getLogger(__name__)
...
def foobar():
with LogCatcher(LOG) as catcher_in_rye:
LOG.warning("Running Kids")
catcher_in_rye.assertInLogs("Running Kids")
"""
def __init__(self, logger):
self.logger = getattr(logger, "logger", logger)
self.handler = CatcherHandler()
def __enter__(self):
self.logger.addHandler(self.handler)
return self
def __exit__(self, type_, value, traceback):
self.logger.removeHandler(self.handler)
def assertInLogs(self, msg):
"""Assert that `msg' is a substring at least of one logged message.
:param msg: Substring to look for.
:return: Log messages where the `msg' was found.
Raises AssertionError if none.
"""
in_logs = [record.msg
for record in self.handler.buffer if msg in record.msg]
if not in_logs:
raise AssertionError("Expected `%s' is not in logs" % msg)
return in_logs
def fetchLogRecords(self):
"""Returns all logged Records."""
return self.handler.buffer
def fetchLogs(self):
"""Returns all logged messages."""
return [record.msg for record in self.handler.buffer]
def _log_wrapper(obj, log_function, msg, **kw):
"""A logging wrapper for any method of a class.
Class instances that use this decorator should have self.task or
self.deployment attribute. The wrapper produces logs messages both
before and after the method execution, in the following format
(example for tasks):
"Task <Task UUID> | Starting: <Logging message>"
[Method execution...]
"Task <Task UUID> | Completed: <Logging message>"
:param obj: task or deployment which must be attribute of "self"
:param log_function: Logging method to be used, e.g. LOG.info
:param msg: Text message (possibly parameterized) to be put to the log
:param **kw: Parameters for msg
"""
def decorator(f):
@functools.wraps(f)
def wrapper(self, *args, **kwargs):
params = {"msg": msg % kw, "obj_name": obj.title(),
"uuid": getattr(self, obj)["uuid"]}
log_function(_("%(obj_name)s %(uuid)s | Starting: %(msg)s") %
params)
result = f(self, *args, **kwargs)
log_function(_("%(obj_name)s %(uuid)s | Completed: %(msg)s") %
params)
return result
return wrapper
return decorator
def log_task_wrapper(log_function, msg, **kw):
return _log_wrapper("task", log_function, msg, **kw)
def log_deploy_wrapper(log_function, msg, **kw):
return _log_wrapper("deployment", log_function, msg, **kw)
def log_verification_wrapper(log_function, msg, **kw):
return _log_wrapper("verification", log_function, msg, **kw)
def log_deprecated(message, rally_version, log_function=None, once=False):
"""A wrapper marking a certain method as deprecated.
:param message: Message that describes why the method was deprecated
:param rally_version: version of Rally when the method was deprecated
:param log_function: Logging method to be used, e.g. LOG.info
:param once: Show only once (default is each)
"""
log_function = log_function or LOG.warning
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
if (not once) or (not getattr(f, "_warned_dep_method", False)):
log_function("'%(func)s' is deprecated in Rally v%(version)s: "
"%(msg)s" % {"msg": message,
"version": rally_version,
"func": f.__name__})
setattr(f, "_warned_dep_method", once)
return f(*args, **kwargs)
return wrapper
return decorator
def log_deprecated_args(message, rally_version, deprecated_args,
log_function=None, once=False):
"""A wrapper marking certain arguments as deprecated.
:param message: Message that describes why the arguments were deprecated
:param rally_version: version of Rally when the arguments were deprecated
:param deprecated_args: List of deprecated args.
:param log_function: Logging method to be used, e.g. LOG.info
:param once: Show only once (default is each)
"""
log_function = log_function or LOG.warning
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
if (not once) or (not getattr(f, "_warned_dep_args", False)):
deprecated = ", ".join([
"`%s'" % x for x in deprecated_args if x in kwargs])
if deprecated:
log_function(
"%(msg)s (args %(args)s deprecated in Rally "
"v%(version)s)" %
{"msg": message, "version": rally_version,
"args": deprecated})
setattr(f, "_warned_dep_args", once)
result = f(*args, **kwargs)
return result
return wrapper
return decorator
def is_debug():
return CONF.debug or CONF.rally_debug

View File

@ -14,7 +14,7 @@
import itertools
from rally.common import log
from rally.common import logging
from rally import osclients
from rally.plugins.openstack.context.cleanup import base as cleanup_base
from rally.plugins.openstack.context.keystone import users
@ -34,7 +34,7 @@ from rally.verification.tempest import config as tempest_conf
def list_opts():
return [
("DEFAULT",
itertools.chain(log.DEBUG_OPTS,
itertools.chain(logging.DEBUG_OPTS,
osclients.OSCLIENTS_OPTS)),
("benchmark",
itertools.chain(cinder_utils.CINDER_BENCHMARK_OPTS,

View File

@ -21,7 +21,7 @@ from oslo_utils import importutils
import rally
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -66,7 +66,7 @@ import paramiko
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -27,7 +27,7 @@ import time
from six import moves
from rally.common import log as logging
from rally.common import logging
from rally import exceptions
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ import jsonschema
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import plugin
from rally import consts
from rally.deployment.serverprovider import provider

View File

@ -18,7 +18,7 @@ import os
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally import consts
from rally.deployment import engine

View File

@ -19,7 +19,7 @@ import netaddr
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally.deployment import engine
from rally.deployment.serverprovider import provider

View File

@ -19,7 +19,7 @@ import time
import requests
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -22,7 +22,7 @@ import six
from six import moves
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.deployment.serverprovider import provider
from rally import exceptions

View File

@ -20,7 +20,7 @@ import os
import novaclient.exceptions
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally.deployment.serverprovider import provider
from rally import exceptions

View File

@ -16,7 +16,7 @@
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ import os
from oslo_config import cfg
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally.common.plugin import plugin
from rally import consts

View File

@ -20,7 +20,7 @@ import time
from six.moves import queue as Queue
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally.task import runner

View File

@ -20,7 +20,7 @@ import time
from six.moves import queue as Queue
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally.task import runner

View File

@ -15,7 +15,7 @@
from six import moves
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions

View File

@ -13,7 +13,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.context.cleanup import manager as resource_manager

View File

@ -16,7 +16,7 @@
import sys
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.plugins.openstack.context.cleanup import manager

View File

@ -17,7 +17,7 @@ import time
from rally.common import broker
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import discover
from rally.common import utils as rutils
from rally import osclients

View File

@ -17,7 +17,7 @@ from boto import exception as boto_exception
from neutronclient.common import exceptions as neutron_exceptions
from saharaclient.api import base as saharaclient_base
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import discover
from rally.common import utils
from rally.plugins.openstack.context.cleanup import base

View File

@ -13,7 +13,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import osclients

View File

@ -16,7 +16,7 @@ import collections
from rally.common import broker
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.plugins.openstack.scenarios.fuel import utils as fuel_utils

View File

@ -13,7 +13,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.context.cleanup import manager as resource_manager

View File

@ -14,7 +14,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.context.cleanup import manager as resource_manager

View File

@ -15,7 +15,7 @@ import random
import six
from rally.common.i18n import _, _LE
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally import osclients

View File

@ -14,7 +14,7 @@
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally import osclients
from rally.plugins.openstack.context.keystone import users

View File

@ -14,7 +14,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally import osclients

View File

@ -22,7 +22,7 @@ import six
from rally.common import broker
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally.common import utils as rutils
from rally import consts

View File

@ -16,7 +16,7 @@
from oslo_config import cfg
from rally.common.i18n import _
from rally.common import log
from rally.common import logging
from rally.common import utils
from rally import consts as rally_consts
from rally import exceptions
@ -25,7 +25,7 @@ from rally.plugins.openstack.scenarios.manila import utils as manila_utils
from rally.task import context
CONF = cfg.CONF
LOG = log.getLogger(__name__)
LOG = logging.getLogger(__name__)
CONTEXT_NAME = consts.SHARE_NETWORKS_CONTEXT_NAME
@ -124,7 +124,8 @@ class ManilaShareNetworks(context.Context):
self.context["tenants"][tenant_id][CONTEXT_NAME]["sn_iterator"] = (
utils.RAMInt())
@log.log_task_wrapper(LOG.info, _("Enter context: `%s`") % CONTEXT_NAME)
@logging.log_task_wrapper(LOG.info, _("Enter context: `%s`")
% CONTEXT_NAME)
def setup(self):
self.context[CONTEXT_NAME] = {}
if not self.config["use_share_networks"]:
@ -135,7 +136,7 @@ class ManilaShareNetworks(context.Context):
# TODO(vponomaryov): add support of autocreated resources
pass
@log.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME)
@logging.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME)
def cleanup(self):
# TODO(vponomaryov): add cleanup for autocreated resources when appear.
return

View File

@ -19,7 +19,7 @@ import zipfile
from rally.common import fileutils
from rally.common.i18n import _
from rally.common.i18n import _LE
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally import exceptions

View File

@ -16,7 +16,7 @@
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import osclients
from rally.plugins.openstack.wrappers import network

View File

@ -14,7 +14,7 @@
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally import osclients

View File

@ -16,7 +16,7 @@
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally import osclients

View File

@ -13,7 +13,7 @@
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally import osclients

View File

@ -18,7 +18,7 @@ import shutil
import tempfile
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.task import context

View File

@ -16,7 +16,7 @@
from novaclient import exceptions as nova_exceptions
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import osclients

View File

@ -16,7 +16,7 @@
import novaclient.exceptions
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import osclients
from rally.plugins.openstack.context.cleanup import manager as resource_manager
from rally.task import context

View File

@ -13,7 +13,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import osclients

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -14,7 +14,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import osclients
from rally.plugins.openstack.context.quotas import cinder_quotas

View File

@ -16,7 +16,7 @@
from oslo_config import cfg
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions

View File

@ -13,7 +13,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions

View File

@ -17,7 +17,7 @@ import requests
from six.moves.urllib import parse
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import osclients

View File

@ -16,7 +16,7 @@
import requests
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions

View File

@ -14,7 +14,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import osclients

View File

@ -14,7 +14,7 @@
# under the License.
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.plugins.openstack.context.swift import utils as swift_utils

View File

@ -19,7 +19,7 @@ import six
from rally.common import broker
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally import osclients

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.ceilometer import utils
@ -22,8 +22,8 @@ from rally.task import validation
class CeilometerStats(utils.CeilometerScenario):
"""Benchmark scenarios for Ceilometer Stats API."""
@log.log_deprecated("Use 'get_stats' method, now samples are created in "
"context", "0.1.2")
@logging.log_deprecated("Use 'get_stats' method, now samples are created"
"in context", "0.1.2")
@validation.required_services(consts.Service.CEILOMETER)
@validation.required_openstack(users=True)
@scenario.configure()

View File

@ -15,7 +15,7 @@
import random
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.plugins.openstack import scenario

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.ec2 import utils

View File

@ -18,7 +18,7 @@ import time
from oslo_config import cfg
import requests
from rally.common import log as logging
from rally.common import logging
from rally import exceptions
from rally.plugins.openstack import scenario
from rally.task import atomic

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.keystone import utils as kutils
from rally.task import validation

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.manila import utils

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.murano import utils

View File

@ -16,7 +16,7 @@
import random
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import exceptions
from rally.plugins.openstack import scenario
from rally.plugins.openstack.wrappers import network as network_wrapper

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils

View File

@ -15,7 +15,7 @@
import jsonschema
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions as rally_exceptions
from rally.plugins.openstack import scenario

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.sahara import utils

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.sahara import utils

View File

@ -20,7 +20,7 @@ from oslo_utils import uuidutils
from saharaclient.api import base as sahara_base
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally import exceptions

View File

@ -21,7 +21,7 @@ from oslo_config import cfg
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import sshutils
from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils
from rally.plugins.openstack.scenarios.nova import utils as nova_utils

View File

@ -15,7 +15,7 @@
import json
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.plugins.openstack import scenario

View File

@ -14,7 +14,7 @@
import random
from rally.common import log as logging
from rally.common import logging
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.zaqar import utils as zutils

View File

@ -15,7 +15,7 @@
import abc
from rally.common import log as logging
from rally.common import logging
from rally import exceptions
import six

View File

@ -19,7 +19,7 @@ import collections
from keystoneclient import exceptions
import six
from rally.common import log as logging
from rally.common import logging
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ import netaddr
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import utils
from rally import consts
from rally import exceptions

View File

@ -19,7 +19,7 @@ import copy
import jsonschema
import six
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import plugin
from rally.common import utils
from rally import exceptions

View File

@ -23,7 +23,7 @@ import jsonschema
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally import consts
from rally import exceptions

View File

@ -20,7 +20,7 @@ import time
import jsonschema
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import plugin
from rally.common import utils as rutils
from rally import consts

View File

@ -19,7 +19,7 @@ import time
import six
from rally.common import log as logging
from rally.common import logging
from rally.common.plugin import plugin
from rally.common import utils
from rally import consts

View File

@ -22,7 +22,7 @@ from novaclient import exceptions as nova_exc
import six
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions

View File

@ -24,7 +24,7 @@ from six.moves.urllib import parse
from rally.common import db
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from rally.common import objects
from rally.common import utils
from rally import exceptions

View File

@ -25,7 +25,7 @@ from oslo_utils import encodeutils
from rally.common import costilius
from rally.common.i18n import _
from rally.common.io import subunit_v2
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import exceptions
from rally.verification.tempest import config

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import log as logging
from rally.common import logging
from rally import consts
from rally import osclients
from rally.task import context

View File

@ -138,8 +138,8 @@ def check_import_of_logging(logical_line, filename):
N310
"""
excluded_files = ["./rally/common/log.py",
"./tests/unit/test_log.py",
excluded_files = ["./rally/common/logging.py",
"./tests/unit/test_logging.py",
"./tests/ci/rally_verify.py"]
forbidden_imports = ["from oslo_log",
@ -150,7 +150,7 @@ def check_import_of_logging(logical_line, filename):
for forbidden_import in forbidden_imports:
if logical_line.startswith(forbidden_import):
yield (0, "N310 Wrong module for logging is imported. Please "
"use `rally.common.log` instead.")
"use `rally.common.logging` instead.")
@skip_ignored_lines
@ -182,12 +182,12 @@ def no_use_conf_debug_check(logical_line, filename):
N312
"""
excluded_files = ["./rally/common/log.py"]
excluded_files = ["./rally/common/logging.py"]
point = logical_line.find("CONF.debug")
if point != -1 and filename not in excluded_files:
yield(point, "N312 Don't use `CONF.debug`. "
"Function `rally.common.log.is_debug` "
"Function `rally.common.logging.is_debug` "
"should be used instead.")

View File

@ -16,7 +16,7 @@
import mock
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import logging
from tests.unit import test

View File

@ -15,7 +15,7 @@
import mock
from rally.common import log as logging
from rally.common import logging
from rally import exceptions
from rally.plugins.openstack.scenarios.vm import vmtasks
from tests.unit import test

View File

@ -88,17 +88,17 @@ class HackingTestCase(test.TestCase):
bad_imports = ["from oslo_log import log",
"import oslo_log",
"import logging"]
good_imports = ["from rally.common import log",
"from rally.common.log",
"import rally.common.log"]
good_imports = ["from rally.common import logging",
"from rally.common.logging",
"import rally.common.logging"]
for bad_import in bad_imports:
checkres = checks.check_import_of_logging(bad_import, "fakefile")
self.assertIsNotNone(next(checkres))
for bad_import in bad_imports:
checkres = checks.check_import_of_logging(bad_import,
"./rally/common/log.py")
checkres = checks.check_import_of_logging(
bad_import, "./rally/common/logging.py")
self.assertEqual([], list(checkres))
for good_import in good_imports:

View File

@ -17,15 +17,15 @@ import logging
import mock
from rally.common import log
from rally.common import logging as log
from tests.unit import test
class LogTestCase(test.TestCase):
@mock.patch("rally.common.log.CONF")
@mock.patch("rally.common.log.handlers")
@mock.patch("rally.common.log.oslogging")
@mock.patch("rally.common.logging.CONF")
@mock.patch("rally.common.logging.handlers")
@mock.patch("rally.common.logging.oslogging")
def test_setup(self, mock_oslogging, mock_handlers, mock_conf):
proj = "fakep"
@ -45,11 +45,11 @@ class LogTestCase(test.TestCase):
mock_oslogging.getLogger(None).logger.setLevel.assert_called_once_with(
logging.RDEBUG)
@mock.patch("rally.common.log.logging")
@mock.patch("rally.common.log.RallyContextAdapter")
@mock.patch("rally.common.log.oslogging")
@mock.patch("rally.common.logging.log")
@mock.patch("rally.common.logging.RallyContextAdapter")
@mock.patch("rally.common.logging.oslogging")
def test_getLogger(self, mock_oslogging, mock_rally_context_adapter,
mock_logging):
mock_log):
name = "fake"
vers = "fake"
@ -59,31 +59,31 @@ class LogTestCase(test.TestCase):
self.assertIn(name, mock_oslogging._loggers)
mock_rally_context_adapter.assert_called_once_with(
mock_logging.getLogger(name),
mock_log.getLogger(name),
{"project": "rally", "version": vers})
self.assertEqual(mock_oslogging._loggers[name], returned_logger)
class LogRallyContaxtAdapter(test.TestCase):
@mock.patch("rally.common.log.logging")
@mock.patch("rally.common.log.oslogging.KeywordArgumentAdapter")
def test_debug(self, mock_keyword_argument_adapter, mock_logging):
@mock.patch("rally.common.logging.log")
@mock.patch("rally.common.logging.oslogging.KeywordArgumentAdapter")
def test_debug(self, mock_keyword_argument_adapter, mock_log):
mock_logging.RDEBUG = 123
mock_log.RDEBUG = 123
fake_msg = "fake message"
radapter = log.RallyContextAdapter(mock.MagicMock(), "fakep")
radapter.log = mock.MagicMock()
radapter.debug(fake_msg)
radapter.log.assert_called_once_with(mock_logging.RDEBUG,
radapter.log.assert_called_once_with(mock_log.RDEBUG,
fake_msg)
class ExceptionLoggerTestCase(test.TestCase):
@mock.patch("rally.common.log.is_debug")
@mock.patch("rally.common.logging.is_debug")
def test_context(self, mock_is_debug):
# Prepare
mock_is_debug.return_value = True
@ -147,7 +147,7 @@ class CatcherHandlerTestCase(test.TestCase):
class LogCatcherUnitTestCase(test.TestCase):
def setUp(self):
super(LogCatcherUnitTestCase, self).setUp()
patcher = mock.patch("rally.common.log.CatcherHandler")
patcher = mock.patch("rally.common.logging.CatcherHandler")
self.catcher_handler = patcher.start()
self.catcher_handler.return_value.buffer = [
mock.Mock(msg="foo"), mock.Mock(msg="bar")]