Keep a consistent logger name for keystoneauth
As keystoneauth comes out with new releases, it would be convenient if the logger name did not change. Change-Id: Ica4102db27fa6cd2a3eaa1dac647abe02b4543a2
This commit is contained in:
parent
f1cdb20528
commit
36ef23591d
@ -19,7 +19,12 @@ import iso8601
|
||||
import six
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
def get_logger(name):
|
||||
name = name.replace(__name__.split('.')[0], 'keystoneauth')
|
||||
return logging.getLogger(name)
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class positional(object):
|
||||
|
@ -21,14 +21,13 @@ This includes functions like url_for which allow you to retrieve URLs and the
|
||||
raw data specified in version discovery responses.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
from keystoneauth1 import exceptions
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_LOGGER = utils.get_logger(__name__)
|
||||
|
||||
|
||||
@utils.positional()
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
||||
@ -20,7 +19,7 @@ from keystoneauth1 import discover
|
||||
from keystoneauth1 import exceptions
|
||||
from keystoneauth1 import plugin
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
LOG = utils.get_logger(__name__)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
|
@ -11,17 +11,17 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import logging
|
||||
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
from keystoneauth1 import discover
|
||||
from keystoneauth1 import exceptions
|
||||
from keystoneauth1.identity import base
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
LOG = utils.get_logger(__name__)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
|
@ -10,15 +10,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
from keystoneauth1 import discover
|
||||
from keystoneauth1.identity.generic import base
|
||||
from keystoneauth1.identity import v2
|
||||
from keystoneauth1.identity import v3
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
LOG = utils.get_logger(__name__)
|
||||
|
||||
|
||||
class Password(base.BaseGenericPlugin):
|
||||
|
@ -10,14 +10,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from keystoneauth1 import _utils as utils
|
||||
from keystoneauth1 import discover
|
||||
from keystoneauth1.identity.generic import base
|
||||
from keystoneauth1.identity import v2
|
||||
from keystoneauth1.identity import v3
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
LOG = utils.get_logger(__name__)
|
||||
|
||||
|
||||
class Token(base.BaseGenericPlugin):
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
||||
@ -20,7 +19,7 @@ from keystoneauth1 import access
|
||||
from keystoneauth1 import exceptions
|
||||
from keystoneauth1.identity import base
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_logger = utils.get_logger(__name__)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
||||
@ -20,7 +19,7 @@ from keystoneauth1 import access
|
||||
from keystoneauth1 import exceptions
|
||||
from keystoneauth1.identity import base
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_logger = utils.get_logger(__name__)
|
||||
|
||||
__all__ = ['Auth', 'AuthMethod', 'AuthConstructor', 'BaseAuth']
|
||||
|
||||
|
@ -38,7 +38,7 @@ except ImportError:
|
||||
|
||||
USER_AGENT = 'keystoneauth1'
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
_logger = utils.get_logger(__name__)
|
||||
|
||||
|
||||
class _JSONEncoder(json.JSONEncoder):
|
||||
|
22
keystoneauth1/tests/unit/test_utils.py
Normal file
22
keystoneauth1/tests/unit/test_utils.py
Normal file
@ -0,0 +1,22 @@
|
||||
# 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 testtools
|
||||
|
||||
from keystoneauth1 import _utils
|
||||
|
||||
|
||||
class UtilsTests(testtools.TestCase):
|
||||
|
||||
def test_get_logger(self):
|
||||
self.assertEqual('keystoneauth.tests.unit.test_utils',
|
||||
_utils.get_logger(__name__).name)
|
Loading…
Reference in New Issue
Block a user