From b9ce7e59033e99b75b7e1dcf759a278d9320f596 Mon Sep 17 00:00:00 2001 From: ZhiQiang Fan Date: Tue, 26 Apr 2016 02:55:59 +0800 Subject: [PATCH] replace logging with oslo.log oslo.log provides more features and is a fundamental recommended library to use. Also the library oslo.log provides compatibility for log levels, logging namespace is not needed. Change-Id: I5636cdf3f804d4f811bd05add3fb42c0beea58a2 --- designate/backend/impl_infoblox/config.py | 5 ++--- designate/backend/impl_infoblox/connector.py | 4 ++-- .../impl_infoblox/object_manipulator.py | 5 +++-- designate/hookpoints.py | 19 +++++++++---------- designate/network_api/__init__.py | 4 ++-- designate/notification_handler/__init__.py | 5 +++-- designate/objects/adapters/base.py | 4 ++-- designate/objects/recordset.py | 4 ++-- designate/sqlalchemy/utils.py | 4 ++-- .../tests/test_pool_manager/test_service.py | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/designate/backend/impl_infoblox/config.py b/designate/backend/impl_infoblox/config.py index 50acfdac..f772a43b 100644 --- a/designate/backend/impl_infoblox/config.py +++ b/designate/backend/impl_infoblox/config.py @@ -13,11 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import logging - from oslo_config import cfg +from oslo_log import log -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) cfg.CONF.register_group(cfg.OptGroup( diff --git a/designate/backend/impl_infoblox/connector.py b/designate/backend/impl_infoblox/connector.py index 5dd01e68..a6332835 100644 --- a/designate/backend/impl_infoblox/connector.py +++ b/designate/backend/impl_infoblox/connector.py @@ -16,8 +16,8 @@ # under the License. import json as jsonutils -import logging +from oslo_log import log from six.moves.urllib import parse import requests @@ -25,7 +25,7 @@ from designate.backend.impl_infoblox.config import cfg from designate.backend.impl_infoblox import ibexceptions as exc -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) class Infoblox(object): diff --git a/designate/backend/impl_infoblox/object_manipulator.py b/designate/backend/impl_infoblox/object_manipulator.py index 00529563..8871e72d 100644 --- a/designate/backend/impl_infoblox/object_manipulator.py +++ b/designate/backend/impl_infoblox/object_manipulator.py @@ -15,13 +15,14 @@ import gettext -import logging + +from oslo_log import log from designate.backend.impl_infoblox import ibexceptions as exc _ = gettext.gettext -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) class InfobloxObjectManipulator(object): diff --git a/designate/hookpoints.py b/designate/hookpoints.py index 9891518c..80c590f1 100644 --- a/designate/hookpoints.py +++ b/designate/hookpoints.py @@ -15,11 +15,10 @@ # under the License. import sys import functools -import logging as logmodule import pkg_resources from oslo_config import cfg -from oslo_log import log as logging +from oslo_log import log from stevedore import hook @@ -28,19 +27,19 @@ class HookLog(object): messages for later use. """ LVLS = dict( - debug=logmodule.DEBUG, - info=logmodule.INFO, - warning=logmodule.WARNING, - error=logmodule.ERROR, - critical=logmodule.CRITICAL, - exception=logmodule.ERROR, + debug=log.DEBUG, + info=log.INFO, + warning=log.WARNING, + error=log.ERROR, + critical=log.CRITICAL, + exception=log.ERROR, ) def __init__(self): self.messages = [] def log(self, logger=None): - logger = logging.getLogger(__name__) + logger = log.getLogger(__name__) for level, msg, args, kw in self.messages: logger.log(level, msg, *args, **kw) @@ -95,7 +94,7 @@ class BaseHook(object): class hook_point(object): NAMESPACE = 'designate.hook_point' - LOG_LEVEL = logmodule.INFO + LOG_LEVEL = log.INFO def __init__(self, name=None): self._name = name diff --git a/designate/network_api/__init__.py b/designate/network_api/__init__.py index 7115c35e..95cb7b6f 100644 --- a/designate/network_api/__init__.py +++ b/designate/network_api/__init__.py @@ -13,14 +13,14 @@ # 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 oslo_log import log from designate.network_api.base import NetworkAPI -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) cfg.CONF.register_opts([ cfg.StrOpt('network_api', default='neutron', help='Which API to use.') diff --git a/designate/notification_handler/__init__.py b/designate/notification_handler/__init__.py index e3da3521..9ef7d76d 100644 --- a/designate/notification_handler/__init__.py +++ b/designate/notification_handler/__init__.py @@ -13,12 +13,13 @@ # 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_log import log from designate.notification_handler.base import NotificationHandler -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) def get_notification_handlers(enabled_extensions): diff --git a/designate/objects/adapters/base.py b/designate/objects/adapters/base.py index ceb5bbce..220b10b9 100644 --- a/designate/objects/adapters/base.py +++ b/designate/objects/adapters/base.py @@ -11,8 +11,8 @@ # 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_log import log import six from designate import objects @@ -20,7 +20,7 @@ from designate import exceptions from designate.i18n import _LE from designate.i18n import _LI -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) class DesignateObjectAdapterMetaclass(type): diff --git a/designate/objects/recordset.py b/designate/objects/recordset.py index c2aca26c..eab98cdd 100644 --- a/designate/objects/recordset.py +++ b/designate/objects/recordset.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -import logging from copy import deepcopy from oslo_config import cfg +from oslo_log import log import six from designate import exceptions @@ -26,7 +26,7 @@ from designate.objects.validation_error import ValidationError from designate.objects.validation_error import ValidationErrorList -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) cfg.CONF.import_opt('supported_record_type', 'designate') diff --git a/designate/sqlalchemy/utils.py b/designate/sqlalchemy/utils.py index 8c1ac462..01f88d8e 100644 --- a/designate/sqlalchemy/utils.py +++ b/designate/sqlalchemy/utils.py @@ -15,7 +15,6 @@ # 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 import six import sqlalchemy @@ -24,13 +23,14 @@ from sqlalchemy import select from oslo_db.sqlalchemy import utils from oslo_db import exception as oslo_db_exception from oslo_db.sqlalchemy.migration_cli import manager +from oslo_log import log from designate.i18n import _ from designate.i18n import _LW from designate import exceptions -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) def get_migration_manager(repo_path, url, init_version=None): diff --git a/designate/tests/test_pool_manager/test_service.py b/designate/tests/test_pool_manager/test_service.py index a3e79684..9b1971d5 100644 --- a/designate/tests/test_pool_manager/test_service.py +++ b/designate/tests/test_pool_manager/test_service.py @@ -14,9 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. -import logging import uuid +from oslo_log import log import oslo_messaging as messaging from mock import call from mock import Mock @@ -32,7 +32,7 @@ from designate.tests.test_pool_manager import PoolManagerTestCase from designate.tests.test_pool_manager import POOL_DICT import designate.pool_manager.service as pm_module -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) class PoolManagerServiceNoopTest(PoolManagerTestCase):