From: Sergey Vilgelm Date: Mon, 10 Aug 2015 12:46:27 +0000 (+0300) Subject: Use oslo.log library instead of system logging module X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5ff3439df5942a9cb150ac4cd3da987e20a31f5c;p=openstack-build%2Fneutron-build.git Use oslo.log library instead of system logging module The constants of log levels were added in the 1.8 version of the oslo.log library. So we can replace all usage of system logging module with log module from oslo.log. Change-Id: I2992df0bec6337aefa8a75d4853b132bd134fa42 Closes-Bug: 1481370 --- diff --git a/neutron/common/utils.py b/neutron/common/utils.py index 94607e644..fbb6a8c07 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -22,7 +22,6 @@ import datetime import errno import functools import hashlib -import logging as std_logging import multiprocessing import netaddr import os @@ -282,7 +281,7 @@ def is_extension_supported(plugin, ext_alias): def log_opt_values(log): - cfg.CONF.log_opt_values(log, std_logging.DEBUG) + cfg.CONF.log_opt_values(log, logging.DEBUG) def get_random_mac(base_mac): diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index b0d0ef3d3..28d4735a6 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -14,7 +14,6 @@ # under the License. import hashlib -import logging as std_logging import signal import sys import time @@ -1660,7 +1659,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, self.conf.reload_config_files() config.setup_logging() LOG.debug('Full set of CONF:') - self.conf.log_opt_values(LOG, std_logging.DEBUG) + self.conf.log_opt_values(LOG, logging.DEBUG) self.catch_sighup = False return self.run_daemon_loop diff --git a/neutron/policy.py b/neutron/policy.py index c3f6746bb..e1d955a60 100644 --- a/neutron/policy.py +++ b/neutron/policy.py @@ -18,7 +18,6 @@ Policy engine for neutron. Largely copied from nova. """ import collections -import logging as std_logging import re from oslo_config import cfg @@ -314,7 +313,7 @@ def _prepare_check(context, action, target, pluralized): def log_rule_list(match_rule): - if LOG.isEnabledFor(std_logging.DEBUG): + if LOG.isEnabledFor(logging.DEBUG): rules = _process_rules_list([], match_rule) LOG.debug("Enforcing rules: %s", rules) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 200b601ac..eabe9da2e 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -13,7 +13,6 @@ # under the License. import functools -import logging import pprint import alembic @@ -32,9 +31,6 @@ from neutron.db.migration import cli as migration from neutron.db.migration.models import head as head_models from neutron.tests.common import base -LOG = logging.getLogger(__name__) - - cfg.CONF.import_opt('core_plugin', 'neutron.common.config') CORE_PLUGIN = 'neutron.plugins.ml2.plugin.Ml2Plugin' diff --git a/neutron/tests/tempest/config.py b/neutron/tests/tempest/config.py index c459d76af..200b24736 100644 --- a/neutron/tests/tempest/config.py +++ b/neutron/tests/tempest/config.py @@ -15,7 +15,6 @@ from __future__ import print_function -import logging as std_logging import os from oslo_config import cfg @@ -1191,7 +1190,7 @@ class TempestConfigPrivate(object): register_opts() self._set_attrs() if parse_conf: - cfg.CONF.log_opt_values(LOG, std_logging.DEBUG) + cfg.CONF.log_opt_values(LOG, logging.DEBUG) class TempestConfigProxy(object): @@ -1199,15 +1198,15 @@ class TempestConfigProxy(object): _path = None _extra_log_defaults = [ - ('keystoneclient.session', std_logging.INFO), - ('paramiko.transport', std_logging.INFO), - ('requests.packages.urllib3.connectionpool', std_logging.WARN), + ('keystoneclient.session', logging.INFO), + ('paramiko.transport', logging.INFO), + ('requests.packages.urllib3.connectionpool', logging.WARN), ] def _fix_log_levels(self): """Tweak the oslo log defaults.""" for name, level in self._extra_log_defaults: - std_logging.getLogger(name).setLevel(level) + logging.getLogger(name).logger.setLevel(level) def __getattr__(self, attr): if not self._config: diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_helpers.py b/neutron/tests/unit/plugins/ml2/drivers/test_helpers.py index 018d53bd0..594f559e9 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_helpers.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_helpers.py @@ -14,9 +14,9 @@ # under the License. import fixtures -import logging as std_logging import mock from oslo_db import exception as exc +from oslo_log import log as logging from sqlalchemy.orm import query import neutron.db.api as db @@ -47,7 +47,7 @@ class HelpersTest(testlib_api.SqlTestCase): fixtures.FakeLogger( name=helpers.__name__, format=base.LOG_FORMAT, - level=std_logging.DEBUG + level=logging.DEBUG )) def check_raw_segment(self, expected, observed): diff --git a/neutron/wsgi.py b/neutron/wsgi.py index dd71a9b90..9e0d4ebfc 100644 --- a/neutron/wsgi.py +++ b/neutron/wsgi.py @@ -19,7 +19,6 @@ Utility methods for working with WSGI servers from __future__ import print_function import errno -import logging as std_logging import os import socket import ssl @@ -240,7 +239,7 @@ class Server(object): # The API service should run in the current process. self._server = service # Dump the initial option values - cfg.CONF.log_opt_values(LOG, std_logging.DEBUG) + cfg.CONF.log_opt_values(LOG, logging.DEBUG) service.start() systemd.notify_once() else: