Align logging on oslo_log

This patch aligns all of Octavia to use oslo_log instead of the built
in python logging. This should provide consistent log formats.

It adds a hacking check to make sure "logging" doesn't come back into
the code.

Change-Id: I9b76c2bb5a5c396faf85df4606f2ca00f23de913
changes/31/575931/6
Michael Johnson 4 years ago
parent 13eab152fb
commit 5af7133a02
  1. 3
      octavia/amphorae/backends/agent/api_server/haproxy_compatibility.py
  2. 2
      octavia/amphorae/backends/agent/api_server/keepalived.py
  3. 2
      octavia/amphorae/backends/agent/api_server/listener.py
  4. 2
      octavia/amphorae/backends/agent/api_server/osutils.py
  5. 2
      octavia/amphorae/backends/agent/api_server/plug.py
  6. 3
      octavia/api/root_controller.py
  7. 3
      octavia/api/v1/controllers/base.py
  8. 3
      octavia/api/v1/controllers/health_monitor.py
  9. 3
      octavia/api/v1/controllers/l7policy.py
  10. 3
      octavia/api/v1/controllers/l7rule.py
  11. 3
      octavia/api/v1/controllers/listener.py
  12. 3
      octavia/api/v1/controllers/member.py
  13. 3
      octavia/api/v1/controllers/pool.py
  14. 3
      octavia/api/v2/controllers/amphora.py
  15. 3
      octavia/api/v2/controllers/base.py
  16. 3
      octavia/api/v2/controllers/health_monitor.py
  17. 3
      octavia/api/v2/controllers/l7policy.py
  18. 3
      octavia/api/v2/controllers/l7rule.py
  19. 3
      octavia/api/v2/controllers/listener.py
  20. 3
      octavia/api/v2/controllers/member.py
  21. 3
      octavia/api/v2/controllers/pool.py
  22. 3
      octavia/common/policy.py
  23. 2
      octavia/common/stats.py
  24. 2
      octavia/controller/worker/controller_worker.py
  25. 2
      octavia/controller/worker/task_utils.py
  26. 3
      octavia/controller/worker/tasks/amphora_driver_tasks.py
  27. 2
      octavia/controller/worker/tasks/compute_tasks.py
  28. 3
      octavia/controller/worker/tasks/database_tasks.py
  29. 3
      octavia/controller/worker/tasks/network_tasks.py
  30. 5
      octavia/db/migration/alembic_migrations/env.py
  31. 4
      octavia/db/migration/cli.py
  32. 15
      octavia/hacking/checks.py
  33. 2
      octavia/tests/unit/common/test_policy.py

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import re
import subprocess
from oslo_log import log as logging
LOG = logging.getLogger(__name__)

@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import os
import stat
import subprocess
import flask
import jinja2
from oslo_log import log as logging
import webob
from octavia.amphorae.backends.agent.api_server import listener

@ -14,7 +14,6 @@
import hashlib
import io
import logging
import os
import re
import shutil
@ -24,6 +23,7 @@ import subprocess
import flask
import jinja2
from oslo_config import cfg
from oslo_log import log as logging
import six
import webob
from werkzeug import exceptions

@ -13,7 +13,6 @@
# under the License.
import ipaddress
import logging
import os
import platform
import shutil
@ -22,6 +21,7 @@ import subprocess
import jinja2
from oslo_config import cfg
from oslo_log import log as logging
import six
import webob
from werkzeug import exceptions

@ -14,7 +14,6 @@
# under the License.
import ipaddress
import logging
import os
import socket
import stat
@ -23,6 +22,7 @@ import subprocess
import jinja2
import netifaces
from oslo_config import cfg
from oslo_log import log as logging
import pyroute2
import six
import webob

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_log import log as logging
from pecan import rest
from wsme import types as wtypes
from wsmeext import pecan as wsme_pecan

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_log import log as logging
from pecan import rest
from stevedore import driver as stevedore_driver

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsmeext import pecan as wsme_pecan

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import oslo_db.exception as oslo_exc
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import oslo_db.exception as oslo_exc
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import oslo_db.exception as oslo_exc
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_utils import excutils
import pecan

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_log import log as logging
from pecan import rest
from wsme import types as wtypes

@ -13,10 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -12,10 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -12,9 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -13,10 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from stevedore import driver as stevedore_driver

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -13,10 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_config import cfg
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
import pecan
from wsme import types as wtypes

@ -12,9 +12,8 @@
"""Policy Engine For Octavia."""
import logging
from oslo_config import cfg
from oslo_log import log as logging
from oslo_policy import policy as oslo_policy
from oslo_utils import excutils

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
from oslo_log import log as logging
from octavia.common import constants
from octavia.common import data_models

@ -13,9 +13,9 @@
# under the License.
#
import logging
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy.orm import exc as db_exceptions
from taskflow.listeners import logging as tf_logging

@ -14,7 +14,7 @@
""" Methods common to the controller work tasks."""
import logging
from oslo_log import log as logging
from octavia.common import constants
from octavia.db import api as db_apis

@ -13,9 +13,8 @@
# under the License.
#
import logging
from oslo_config import cfg
from oslo_log import log as logging
import six
from stevedore import driver as stevedore_driver
from taskflow import task

@ -13,10 +13,10 @@
# under the License.
#
import logging
import time
from oslo_config import cfg
from oslo_log import log as logging
import six
from stevedore import driver as stevedore_driver
from taskflow import task

@ -13,10 +13,9 @@
# under the License.
#
import logging
from oslo_config import cfg
from oslo_db import exception as odb_exceptions
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import uuidutils
import six

@ -13,9 +13,8 @@
# under the License.
#
import logging
from oslo_config import cfg
from oslo_log import log as logging
import six
from taskflow import task
from taskflow.types import failure

@ -14,7 +14,6 @@
from __future__ import with_statement
from logging import config as logging_config
import sys
from alembic import context
@ -30,10 +29,6 @@ except AttributeError:
" alembic actions.")
sys.exit(1)
# Interpret the config file for Python logging.
# This line sets up loggers basically.
logging_config.fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel

@ -20,11 +20,15 @@ from alembic import config as alembic_cfg
from alembic import util as alembic_u
from oslo_config import cfg
from oslo_db import options
from oslo_log import log
from octavia.i18n import _
CONF = cfg.CONF
options.set_defaults(CONF)
log.set_defaults()
log.register_options(CONF)
log.setup(CONF, 'octavia-db-manage')
def do_alembic_command(config, cmd, *args, **kwargs):

@ -69,6 +69,7 @@ no_basestring_re = re.compile(r"\bbasestring\b")
no_iteritems_re = re.compile(r".*\.iteritems\(\)")
no_eventlet_re = re.compile(r'(import|from)\s+[(]?eventlet')
no_line_continuation_backslash_re = re.compile(r'.*(\\)\n')
no_logging_re = re.compile(r'(import|from)\s+[(]?logging')
def _translation_checks_not_enforced(filename):
@ -288,6 +289,19 @@ def revert_must_have_kwargs(logical_line):
yield 0, msg
def check_no_logging_imports(logical_line):
"""O348 - Usage of Python logging module not allowed.
:param logical_line: The logical line to check.
:returns: None if the logical line passes the check, otherwise a tuple
is yielded that contains the offending index in logical line
and a message describe the check validation failure.
"""
if no_logging_re.match(logical_line):
msg = 'O348 Usage of Python logging module not allowed, use oslo_log'
yield logical_line.index('logging'), msg
def factory(register):
register(assert_true_instance)
register(assert_equal_or_not_none)
@ -304,3 +318,4 @@ def factory(register):
register(check_no_eventlet_imports)
register(check_line_continuation_no_backslash)
register(revert_must_have_kwargs)
register(check_no_logging_imports)

@ -12,10 +12,10 @@
"""Test of Policy Engine For Octavia."""
import logging
import tempfile
from oslo_config import fixture as oslo_fixture
from oslo_log import log as logging
from oslo_policy import policy as oslo_policy
import requests_mock

Loading…
Cancel
Save