本文整理汇总了Python中rally.common.log.getLogger函数的典型用法代码示例。如果您正苦于以下问题:Python getLogger函数的具体用法?Python getLogger怎么用?Python getLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getLogger函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_getLogger
def test_getLogger(self, mock_oslogger, mock_radapter, mock_pylogging):
name = "fake"
vers = "fake"
mock_oslogger._loggers = dict()
returned_logger = log.getLogger(name, vers)
self.assertIn(name, mock_oslogger._loggers)
mock_radapter.assert_called_once_with(
mock_pylogging.getLogger(name),
{"project": "rally", "version": vers})
self.assertEqual(mock_oslogger._loggers[name], returned_logger)
开发者ID:esikachev,项目名称:rally,代码行数:13,代码来源:test_log.py
示例2: test_logcatcher
def test_logcatcher(self):
LOG = log.getLogger("testlogger")
LOG.logger.setLevel(log.INFO)
with log.LogCatcher(LOG) as catcher:
LOG.warning("Warning")
LOG.info("Info")
LOG.debug("Debug")
catcher.assertInLogs("Warning")
self.assertRaises(AssertionError, catcher.assertInLogs, "Error")
self.assertEqual(["Warning", "Info"], catcher.fetchLogs())
self.assertEqual(2, len(catcher.fetchLogRecords()))
开发者ID:Pigueiras,项目名称:rally,代码行数:14,代码来源:test_log.py
示例3: _prepare_open_secgroup
# 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 six
from rally.benchmark import context
from rally.common.i18n import _
from rally.common import log as logging
from rally.common import utils
from rally import osclients
from rally.plugins.openstack.wrappers import network
LOG = logging.getLogger(__name__)
SSH_GROUP_NAME = "rally_ssh_open"
def _prepare_open_secgroup(endpoint, secgroup_name):
"""Generate secgroup allowing SSH access and ICMP.
In order to run tests on instances it is necessary to have SSH access.
This function generates a secgroup which allows SSH access as well as ICMP.
:param endpoint: clients endpoint
:param secgroup_name: security group name
:returns: dict with security group details
"""
开发者ID:gmihaiescu,项目名称:rally,代码行数:31,代码来源:secgroup.py
示例4: run
def run(argv, categories):
parser = lambda subparsers: _add_command_parsers(categories, subparsers)
category_opt = cfg.SubCommandOpt("category",
title="Command categories",
help="Available categories",
handler=parser)
CONF.register_cli_opt(category_opt)
help_msg = ("Additional custom plugin locations. Multiple files or "
"directories may be specified. All plugins in the specified"
" directories and subdirectories will be imported. Plugins in"
" /opt/rally/plugins and ~/.rally/plugins will always be "
"imported.")
CONF.register_cli_opt(cfg.ListOpt("plugin-paths",
default=os.environ.get(
"RALLY_PLUGIN_PATHS"),
help=help_msg))
try:
CONF(argv[1:], project="rally", version=version.version_string(),
default_config_files=find_config_files(CONFIG_SEARCH_PATHS))
logging.setup("rally")
if not CONF.get("log_config_append"):
# The below two lines are to disable noise from request module. The
# standard way should be we make such lots of settings on the root
# rally. However current oslo codes doesn't support such interface.
# So I choose to use a 'hacking' way to avoid INFO logs from
# request module where user didn't give specific log configuration.
# And we could remove this hacking after oslo.log has such
# interface.
LOG.debug("INFO logs from urllib3 and requests module are hide.")
requests_log = logging.getLogger("requests").logger
requests_log.setLevel(logging.WARNING)
urllib3_log = logging.getLogger("urllib3").logger
urllib3_log.setLevel(logging.WARNING)
# NOTE(wtakase): This is for suppressing boto error logging.
LOG.debug("ERROR log from boto module is hide.")
boto_log = logging.getLogger("boto").logger
boto_log.setLevel(logging.CRITICAL)
except cfg.ConfigFilesNotFoundError:
cfgfile = CONF.config_file[-1] if CONF.config_file else None
if cfgfile and not os.access(cfgfile, os.R_OK):
st = os.stat(cfgfile)
print(_("Could not read %s. Re-running with sudo") % cfgfile)
try:
os.execvp("sudo", ["sudo", "-u", "#%s" % st.st_uid] + sys.argv)
except Exception:
print(_("sudo failed, continuing as if nothing happened"))
print(_("Please re-run %s as root.") % argv[0])
return(2)
if CONF.category.name == "version":
print(version.version_string())
return(0)
if CONF.category.name == "bash-completion":
print(_generate_bash_completion_script())
return(0)
fn = CONF.category.action_fn
fn_args = [encodeutils.safe_decode(arg)
for arg in CONF.category.action_args]
fn_kwargs = {}
for k in CONF.category.action_kwargs:
v = getattr(CONF.category, "action_kwarg_" + k)
if v is None:
continue
if isinstance(v, six.string_types):
v = encodeutils.safe_decode(v)
fn_kwargs[k] = v
# call the action with the remaining arguments
# check arguments
try:
validate_args(fn, *fn_args, **fn_kwargs)
except MissingArgs as e:
# NOTE(mikal): this isn't the most helpful error message ever. It is
# long, and tells you a lot of things you probably don't want to know
# if you just got a single arg wrong.
print(fn.__doc__)
CONF.print_help()
print("Missing arguments:")
for missing in e.missing:
for arg in fn.args:
if arg[1].get("dest", "").endswith(missing):
print(" " + arg[0][0])
break
return(1)
try:
for path in CONF.plugin_paths or []:
discover.load_plugins(path)
validate_deprecated_args(argv, fn)
if getattr(fn, "_suppress_warnings", False):
#.........这里部分代码省略.........
开发者ID:onecloud,项目名称:gbp-rally,代码行数:101,代码来源:cliutils.py
注:本文中的rally.common.log.getLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论