]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Logging module cleanup
authorZhongyue Luo <zhongyue.nah@intel.com>
Thu, 3 Jan 2013 06:31:49 +0000 (14:31 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Thu, 3 Jan 2013 08:20:56 +0000 (16:20 +0800)
Replaced logging with openstack.common.log
Removed imports where logging is not used

Fixes bug #1095541

Change-Id: I5b03d9697dde3ef3520f67d1d8166f7af7689551

17 files changed:
HACKING.rst
quantum/common/test_lib.py
quantum/debug/commands.py
quantum/debug/debug_agent.py
quantum/extensions/credential.py
quantum/extensions/multiport.py
quantum/extensions/qos.py
quantum/plugins/metaplugin/meta_quantum_plugin.py
quantum/plugins/metaplugin/proxy_quantum_plugin.py
quantum/tests/__init__.py
quantum/tests/unit/_test_rootwrap_exec.py
quantum/tests/unit/database_stubs.py
quantum/tests/unit/test_api_v2.py
quantum/tests/unit/test_db_plugin.py
quantum/tests/unit/test_extensions.py
quantum/tests/unit/test_l3_plugin.py
quantum/tests/unit/test_quantum_manager.py

index ff7d86891d7f18524ed564329367407dc63cb491..0423c41e120d346017c35649d21b16e1fd6a2a48 100644 (file)
@@ -63,7 +63,6 @@ Human Alphabetical Order Examples
 Example::
 
   import httplib
-  import logging
   import random
   import StringIO
   import time
@@ -76,6 +75,7 @@ Example::
   from quantum.api import ports
   from quantum.db import models
   from quantum.extensions import multiport
+  from quantum.openstack.common import log as logging
   import quantum.manager
   from quantum import service
 
index 087fab19bd96d1c1d3b549489bf9cc47c5436164..dee94cfc7500904dc3d9d20d5ebd4a20d419a2b4 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2010 OpenStack, LLC
+# Copyright (c) 2010 OpenStack, LLC
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,7 +37,6 @@
 #    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 #    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-import logging
 import sys
 import unittest
 
@@ -259,13 +258,6 @@ class QuantumTestRunner(core.TextTestRunner):
 
 
 def run_tests(c=None):
-    logger = logging.getLogger()
-    hdlr = logging.StreamHandler()
-    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
-    hdlr.setFormatter(formatter)
-    logger.addHandler(hdlr)
-    logger.setLevel(logging.DEBUG)
-
     # NOTE(bgh): I'm not entirely sure why but nose gets confused here when
     # calling run_tests from a plugin directory run_tests.py (instead of the
     # main run_tests.py).  It will call run_tests with no arguments and the
index b80b986a30a77cea313e5ec657977d31525ef492..4a641ce60e79e1e93fcd9bdb38669004e6f33ed5 100644 (file)
@@ -1,5 +1,5 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
 # Copyright 2012,  Nachi Ueno,  NTT MCL,  Inc.
 # All Rights Reserved.
 #
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import logging
-
 from cliff import lister
-
 from quantumclient.common import utils
 from quantumclient.quantum.v2_0.port import _format_fixed_ips
 from quantumclient.quantum.v2_0 import QuantumCommand
 
+from quantum.openstack.common import log as logging
+
 
 class ProbeCommand(QuantumCommand):
     log = logging.getLogger(__name__ + '.ProbeCommand')
index 92dc452f9fc26b12a64c46a855060a8b2fb8aa12..ac96e8e5ee20b998244731797afefa7273a74d86 100644 (file)
@@ -1,5 +1,5 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
 # Copyright 2012,  Nachi Ueno,  NTT MCL,  Inc.
 # All Rights Reserved.
 #
@@ -17,7 +17,6 @@
 
 import datetime
 import errno
-import logging
 import os
 import shlex
 import socket
@@ -32,9 +31,11 @@ from quantum.agent.linux import ip_lib
 from quantum.agent.linux import utils
 from quantum.openstack.common import cfg
 from quantum.openstack.common import importutils
+from quantum.openstack.common import log as logging
 from quantumclient.v2_0 import client
 
-LOG = logging.getLogger('test-agent')
+
+LOG = logging.getLogger(__name__)
 
 DEVICE_OWNER_PROBE = 'network:probe'
 
index 24caa6c34fb336d48177dd508ff513a4a9c1c383..3bcf0d7ccad041bd43b2669b403af9e33904ee8c 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2011 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2011 Cisco Systems, 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
@@ -16,8 +17,6 @@
 #
 # @author: Ying Liu, Cisco Systems, Inc.
 
-import logging
-
 from webob import exc
 
 from quantum.api import api_common as common
@@ -29,9 +28,6 @@ from quantum.plugins.cisco.common import cisco_faults as faults
 from quantum import wsgi
 
 
-LOG = logging.getLogger('quantum.api.credentials')
-
-
 class Credential(object):
     """extension class Credential"""
     def __init__(self):
index 5f632eabc126c45f4a28df5bfde99bab114a4dea..eb7489fd13c28ca2b79be6f8f4c57029c4be8ff2 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2011 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2011 Cisco Systems, 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
@@ -16,8 +17,6 @@
 #
 # @author: Ying Liu, Cisco Systems, Inc.
 
-import logging
-
 from webob import exc
 
 from quantum.api import api_common as common
@@ -28,9 +27,6 @@ from quantum.plugins.cisco.common import cisco_faults as faults
 from quantum import wsgi
 
 
-LOG = logging.getLogger('quantum.api.multiports')
-
-
 class Multiport(object):
     """extension class multiport"""
     def __init__(self):
index 179eaa4a992ed9f108da65a28db406053c242dd2..f1bd5b2b72064af0d24511250512c61431b44e84 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2011 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2011 Cisco Systems, 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
@@ -16,8 +17,6 @@
 #
 # @author: Ying Liu, Cisco Systems, Inc.
 
-import logging
-
 from webob import exc
 
 from quantum.api import api_common as common
@@ -29,9 +28,6 @@ from quantum.plugins.cisco.common import cisco_faults as faults
 from quantum import wsgi
 
 
-LOG = logging.getLogger('quantum.api.qoss')
-
-
 class Qos(object):
     """Qos extension file"""
     def __init__(self):
index 27029962fa4657890004d95ca0d76098219e2a79..5f722083a778169d802a6f654d0fb0d0055b0c27 100644 (file)
@@ -1,5 +1,5 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
 # Copyright 2012, Nachi Ueno, NTT MCL, Inc.
 # All Rights Reserved.
 #
@@ -15,8 +15,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import logging
-
 from quantum.api.v2 import attributes
 from quantum.common import exceptions as exc
 from quantum.common.utils import find_config_file
@@ -27,13 +25,15 @@ from quantum.db import models_v2
 from quantum.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER)
 from quantum.openstack.common import cfg
 from quantum.openstack.common import importutils
+from quantum.openstack.common import log as logging
 from quantum.plugins.metaplugin.common import config
 from quantum.plugins.metaplugin import meta_db_v2
 from quantum.plugins.metaplugin.meta_models_v2 import (NetworkFlavor,
                                                        RouterFlavor)
 from quantum import policy
 
-LOG = logging.getLogger("metaplugin")
+
+LOG = logging.getLogger(__name__)
 
 
 # Metaplugin  Exceptions
index 9164fbc36d1a6fbc71edba6ff3f6c938382419cb..2ffb500475e037afed2c0f6318ab3997d8084b81 100644 (file)
@@ -1,5 +1,5 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
+
 # Copyright 2012, Nachi Ueno, NTT MCL, Inc.
 # All Rights Reserved.
 #
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import logging
-
 from quantum.db import api as db
 from quantum.db import db_base_plugin_v2
 from quantum.db import l3_db
 from quantum.db import models_v2
 from quantum.openstack.common import cfg
+from quantum.openstack.common import log as logging
 from quantumclient.common import exceptions
 from quantumclient.v2_0 import client
 
index 9578283b2d65e9ea45d938f9f20f71a12cb7eef4..671d3c173e23ddcfd40b194a71dbaf272a8afba1 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright (c) 2011 OpenStack, LLC.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -14,6 +14,3 @@
 #    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
-logging.basicConfig()
index 66fe434d771f3c66aa42b2d81ec872e639fea2d0..16cd6e6e36261af768f4cb2da137db559918f775 100644 (file)
@@ -1,4 +1,6 @@
-# Copyright 2012 OpenStack LLC
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2012 OpenStack, LLC
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-
+import os
 import unittest
+
 import mock
+
 from quantum.agent.linux import utils
-import os
-import logging
+import quantum.openstack.common import log as logging
 
 
-LOG = logging.getLogger('quantum.tests.database_stubs')
+LOG = logging.getLogger(__name__)
 
 
 class RootwrapTestExec(unittest.TestCase):
index 166824dc99f6c2968830342ec743bd986dbdf96a..583f166013f84335200cbeb97e279447798f0efc 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
 # Copyright 2011, Cisco Systems, 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
 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 #    License for the specific language governing permissions and limitations
 #    under the License.
+#
 # @author: Rohit Agarwalla, Cisco Systems, Inc.
 
-"""
-stubs.py provides interface methods for
-the database test cases
-"""
-import logging
+""" stubs.py provides interface methods for the database test cases """
 
 from quantum.db import api as db
+from quantum.openstack.common import log as logging
 
 
-LOG = logging.getLogger('quantum.tests.database_stubs')
+LOG = logging.getLogger(__name__)
 
 
 class QuantumDB(object):
index 9717b1d065999af47adb4088df745b8ff97bc53e..5389434b5363c61288e429263c28b1fa04da11ed 100644 (file)
@@ -1,20 +1,20 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2012 OpenStack LLC.
+# Copyright (c) 2012 OpenStack, LLC.
 # 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
+#    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
+#         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 spec
+#    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 logging
 import os
 import unittest
 
@@ -35,8 +35,6 @@ from quantum.openstack.common.notifier import api as notifer_api
 from quantum.openstack.common import uuidutils
 
 
-LOG = logging.getLogger(__name__)
-
 ROOTDIR = os.path.dirname(os.path.dirname(__file__))
 ETCDIR = os.path.join(ROOTDIR, 'etc')
 EXTDIR = os.path.join(ROOTDIR, 'unit/extensions')
index f93ef151cfe462c519294faa29dd29bdcd3ae7f4..08a0bc92fa1a43463100228094cb0f6f2a4ee53b 100644 (file)
@@ -1,25 +1,27 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
 # Copyright (c) 2012 OpenStack, LLC.
+# 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
+#    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
+#         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.
+#    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 contextlib
 import copy
 import datetime
-import logging
-import mock
 import os
 import random
+
+import mock
 import unittest2
 import webob.exc
 
@@ -43,8 +45,6 @@ from quantum.tests.unit.testlib_api import create_request
 from quantum.wsgi import Serializer, JSONDeserializer
 
 
-LOG = logging.getLogger(__name__)
-
 DB_PLUGIN_KLASS = 'quantum.db.db_base_plugin_v2.QuantumDbPluginV2'
 ROOTDIR = os.path.dirname(os.path.dirname(__file__))
 ETCDIR = os.path.join(ROOTDIR, 'etc')
index ffabca041f3cde4609544f03a3aaedd9775fd6ec..9feddd799b00d96052b1a22a0a38bf2bce75449b 100644 (file)
@@ -1,5 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2011 OpenStack LLC.
+
+# Copyright (c) 2011 OpenStack, LLC.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -14,7 +15,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import logging
 import os
 import unittest
 
@@ -33,6 +33,7 @@ from quantum.common import config
 from quantum.common import exceptions
 from quantum.db.db_base_plugin_v2 import QuantumDbPluginV2
 from quantum.openstack.common import jsonutils
+from quantum.openstack.common import log as logging
 from quantum.plugins.common import constants
 from quantum.tests.unit import BaseTest
 from quantum.tests.unit.extension_stubs import (
@@ -45,7 +46,7 @@ import quantum.tests.unit.extensions
 from quantum import wsgi
 
 
-LOG = logging.getLogger('quantum.tests.test_extensions')
+LOG = logging.getLogger(__name__)
 
 ROOTDIR = os.path.dirname(os.path.dirname(__file__))
 ETCDIR = os.path.join(ROOTDIR, 'etc')
index 2d138b21f94bbe8436b48b77e591d7913af8e45a..c6af3e4101c40d358d585062b0c8f46da3968cc1 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2012 Nicira Networks, Inc.  All rights reserved.
+# Copyright 2012 Nicira Networks, 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
@@ -20,7 +21,6 @@
 import contextlib
 import copy
 import itertools
-import logging
 import unittest2 as unittest
 
 import mock
@@ -41,6 +41,7 @@ from quantum.db import models_v2
 from quantum.extensions import l3
 from quantum import manager
 from quantum.openstack.common import cfg
+from quantum.openstack.common import log as logging
 from quantum.openstack.common import uuidutils
 from quantum.tests.unit import test_api_v2
 from quantum.tests.unit import test_db_plugin
index a07f69469aa1c6999183a43797268c868778c179..e638e1bf3bb3460fe88ae0524bfb4f08b3d6d387 100644 (file)
@@ -1,19 +1,20 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
 # Copyright (c) 2012 OpenStack, LLC.
+# 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
+#    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
+#         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.
+#    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 logging
 import types
 import unittest2
 
@@ -21,6 +22,7 @@ from quantum.common import config
 from quantum.common.test_lib import test_config
 from quantum.manager import QuantumManager
 from quantum.openstack.common import cfg
+from quantum.openstack.common import log as logging
 from quantum.plugins.common import constants
 from quantum.plugins.services.dummy.dummy_plugin import QuantumDummyPlugin