Switch to oslo.log

Change-Id: I08386ed2c8a2d9e16c57776413a612b8bf8323f7
This commit is contained in:
Endre Karlson 2015-01-21 20:19:50 +01:00
parent 2df77dccea
commit 7eefb71b8b
135 changed files with 187 additions and 880 deletions

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.objects import Record from designate.objects import Record
from designate.notification_handler.base import NotificationHandler from designate.notification_handler.base import NotificationHandler

View File

@ -21,11 +21,10 @@ import os
import socket import socket
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log
from oslo import messaging from oslo import messaging
cfg.CONF.import_opt('default_log_levels', 'designate.openstack.common.log')
cfg.CONF.register_opts([ cfg.CONF.register_opts([
cfg.StrOpt('host', default=socket.gethostname(), cfg.StrOpt('host', default=socket.gethostname(),
help='Name of this node'), help='Name of this node'),
@ -52,17 +51,17 @@ cfg.CONF.register_opts([
]) ])
# Set some Oslo Log defaults # Set some Oslo Log defaults
cfg.CONF.set_default('default_log_levels', log.set_defaults(default_log_levels=[
['amqplib=WARN', 'amqplib=WARN',
'amqp=WARN', 'amqp=WARN',
'sqlalchemy=WARN', 'sqlalchemy=WARN',
'boto=WARN', 'boto=WARN',
'suds=INFO', 'suds=INFO',
'keystone=INFO', 'keystone=INFO',
'eventlet.wsgi.server=WARN', 'eventlet.wsgi.server=WARN',
'stevedore=WARN', 'stevedore=WARN',
'keystonemiddleware.auth_token=INFO', 'keystonemiddleware.auth_token=INFO',
'oslo.messaging=WARN']) 'oslo.messaging=WARN'])
# Set some Oslo RPC defaults # Set some Oslo RPC defaults
messaging.set_transport_defaults('designate') messaging.set_transport_defaults('designate')

View File

@ -17,6 +17,7 @@ import flask
import webob.dec import webob.dec
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging from oslo import messaging
from oslo_log import log as logging
from oslo_middleware import base from oslo_middleware import base
from oslo_middleware import request_id from oslo_middleware import request_id
from oslo.serialization import jsonutils as json from oslo.serialization import jsonutils as json
@ -25,7 +26,6 @@ from oslo_utils import strutils
from designate import exceptions from designate import exceptions
from designate import notifications from designate import notifications
from designate import context from designate import context
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LW from designate.i18n import _LW
from designate.i18n import _LE from designate.i18n import _LE

View File

@ -13,10 +13,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from paste import deploy
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from paste import deploy
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate import exceptions from designate import exceptions
from designate import utils from designate import utils

View File

@ -21,9 +21,9 @@ from werkzeug import wrappers
from werkzeug.routing import BaseConverter from werkzeug.routing import BaseConverter
from werkzeug.routing import ValidationError from werkzeug.routing import ValidationError
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo.serialization import jsonutils from oslo.serialization import jsonutils
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import utils from designate import utils

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate.api.v1 import load_values from designate.api.v1 import load_values
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
import flask import flask
from oslo import messaging from oslo import messaging
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import rpc from designate import rpc

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import objects from designate import objects
from designate import schema from designate import schema

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
import flask import flask
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import schema from designate import schema
from designate import objects from designate import objects

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import flask import flask
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi
from designate.objects import TsigKey from designate.objects import TsigKey

View File

@ -15,9 +15,9 @@
# under the License. # under the License.
import pecan.deploy import pecan.deploy
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.api.v2 import patches # flake8: noqa from designate.api.v2 import patches # flake8: noqa
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,9 +16,9 @@
import pecan import pecan
import pecan.deploy import pecan.deploy
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.api.v2 import patches from designate.api.v2 import patches
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate import utils from designate import utils
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest

View File

@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate import exceptions
from designate.openstack.common import log as logging
from pecan import expose from pecan import expose
from oslo_log import log as logging
from designate import exceptions
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.views.extensions import reports as reports_view from designate.api.v2.views.extensions import reports as reports_view

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.views.extensions import quotas as quotas_view from designate.api.v2.views.extensions import quotas as quotas_view

View File

@ -14,7 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate.openstack.common import log as logging from oslo_log import log as logging
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.controllers.extensions import counts from designate.api.v2.controllers.extensions import counts
from designate.api.v2.controllers.extensions import tenants from designate.api.v2.controllers.extensions import tenants

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.views.extensions import reports as reports_view from designate.api.v2.views.extensions import reports as reports_view

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.views import limits as limits_view from designate.api.v2.views import limits as limits_view

View File

@ -13,11 +13,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate import utils from designate import utils
from designate.openstack.common import log as logging
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.views import nameservers as nameservers_view from designate.api.v2.views import nameservers as nameservers_view

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate import utils from designate import utils
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import schema from designate import schema
from designate import utils from designate import utils

View File

@ -30,10 +30,10 @@ import six
import pecan import pecan
import pecan.rest import pecan.rest
import pecan.routing import pecan.routing
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi
from designate.openstack.common import log as logging
from designate.i18n import _ from designate.i18n import _

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from stevedore import named from stevedore import named
from designate.openstack.common import log as logging
from designate.api.v2.controllers import limits from designate.api.v2.controllers import limits
from designate.api.v2.controllers import reverse from designate.api.v2.controllers import reverse
from designate.api.v2.controllers import schemas from designate.api.v2.controllers import schemas

View File

@ -16,10 +16,10 @@
import os import os
import pecan import pecan
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate import utils from designate import utils
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate import utils from designate import utils
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest

View File

@ -13,12 +13,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest
from designate.api.v2.controllers.zones.tasks.transfer_requests \ from designate.api.v2.controllers.zones.tasks.transfer_requests \
import TransferRequestsController as TRC import TransferRequestsController as TRC
from designate.api.v2.controllers.zones.tasks.transfer_accepts \ from designate.api.v2.controllers.zones.tasks.transfer_accepts \
import TransferAcceptsController as TRA import TransferAcceptsController as TRA
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate import utils from designate import utils
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import pecan import pecan
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import schema from designate import schema
from designate import utils from designate import utils
from designate.api.v2.controllers import rest from designate.api.v2.controllers import rest

View File

@ -16,10 +16,10 @@
import urllib import urllib
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate import objects from designate import objects
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,8 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,8 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,9 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate import objects from designate import objects
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,9 +13,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate import objects from designate import objects
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,8 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,8 +13,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from designate.api.v2.views import base as base_view from designate.api.v2.views import base as base_view
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import policy from designate import policy

View File

@ -13,7 +13,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate.openstack.common import log as logging from oslo_log import log as logging
from designate.backend.base import PoolBackend from designate.backend.base import PoolBackend
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,8 +17,8 @@ import abc
import copy import copy
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.i18n import _LW from designate.i18n import _LW
from designate import exceptions from designate import exceptions
from designate.context import DesignateContext from designate.context import DesignateContext

View File

@ -16,8 +16,8 @@
import socket import socket
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import utils from designate import utils
from designate.backend import base from designate.backend import base

View File

@ -18,13 +18,13 @@ import time
from eventlet import Timeout from eventlet import Timeout
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
import requests import requests
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from designate import exceptions from designate import exceptions
from designate import utils from designate import utils
from designate.backend import base from designate.backend import base
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LW from designate.i18n import _LW

View File

@ -13,7 +13,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate.openstack.common import log as logging from oslo_log import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate.backend import base from designate.backend import base

View File

@ -18,11 +18,11 @@ import time
import requests import requests
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo.serialization import jsonutils as json from oslo.serialization import jsonutils as json
from oslo_utils import importutils from oslo_utils import importutils
from designate import exceptions from designate import exceptions
from designate.openstack.common import log as logging
from designate.backend import base from designate.backend import base
from designate.i18n import _LE from designate.i18n import _LE

View File

@ -20,10 +20,10 @@ import ssl
import eventlet import eventlet
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate.backend import base from designate.backend import base
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,10 +17,10 @@ import copy
import threading import threading
from oslo_db import options from oslo_db import options
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from sqlalchemy.sql import select from sqlalchemy.sql import select
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate.i18n import _LC from designate.i18n import _LC
from designate.backend import base from designate.backend import base

View File

@ -14,9 +14,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from sqlalchemy import MetaData, Table, Column, Boolean from sqlalchemy import MetaData, Table, Column, Boolean
from designate.openstack.common import log as logging
from designate.i18n import _LW from designate.i18n import _LW

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo import messaging from oslo import messaging
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate import rpc from designate import rpc

View File

@ -24,10 +24,10 @@ import random
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging from oslo import messaging
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LC from designate.i18n import _LC
from designate import context as dcontext from designate import context as dcontext

View File

@ -16,8 +16,8 @@
import sys import sys
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.openstack.common import service from designate.openstack.common import service
from designate import rpc from designate import rpc
from designate import utils from designate import utils
@ -30,7 +30,7 @@ CONF.import_opt('workers', 'designate.api', group='service:api')
def main(): def main():
utils.read_config('designate', sys.argv) utils.read_config('designate', sys.argv)
logging.setup('designate') logging.setup(CONF, 'designate')
rpc.init(CONF) rpc.init(CONF)

View File

@ -16,8 +16,8 @@
import sys import sys
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import service from designate import service
from designate import utils from designate import utils
from designate.central import service as central from designate.central import service as central
@ -29,7 +29,7 @@ CONF.import_opt('workers', 'designate.central', group='service:central')
def main(): def main():
utils.read_config('designate', sys.argv) utils.read_config('designate', sys.argv)
logging.setup('designate') logging.setup(CONF, 'designate')
server = central.Service.create(binary='designate-central', server = central.Service.create(binary='designate-central',
service_name='central') service_name='central')

View File

@ -20,11 +20,11 @@ import sys
import eventlet import eventlet
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from stevedore.extension import ExtensionManager from stevedore.extension import ExtensionManager
from designate import utils from designate import utils
from designate.i18n import _ from designate.i18n import _
from designate.openstack.common import log as logging
eventlet.monkey_patch(os=False) eventlet.monkey_patch(os=False)
@ -105,7 +105,7 @@ def main():
try: try:
utils.read_config('designate', sys.argv) utils.read_config('designate', sys.argv)
logging.setup("designate") logging.setup(CONF, 'designate')
except cfg.ConfigFilesNotFoundError: except cfg.ConfigFilesNotFoundError:
cfgfile = CONF.config_file[-1] if CONF.config_file else None cfgfile = CONF.config_file[-1] if CONF.config_file else None
if cfgfile and not os.access(cfgfile, os.R_OK): if cfgfile and not os.access(cfgfile, os.R_OK):

View File

@ -16,8 +16,8 @@
import sys import sys
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import service from designate import service
from designate import utils from designate import utils
from designate.mdns import service as mdns_service from designate.mdns import service as mdns_service
@ -29,7 +29,7 @@ CONF.import_opt('workers', 'designate.mdns', group='service:mdns')
def main(): def main():
utils.read_config('designate', sys.argv) utils.read_config('designate', sys.argv)
logging.setup('designate') logging.setup(CONF, 'designate')
server = mdns_service.Service.create( server = mdns_service.Service.create(
binary='designate-mdns') binary='designate-mdns')

View File

@ -16,10 +16,10 @@
import sys import sys
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import service from designate import service
from designate import utils from designate import utils
from designate.openstack.common import log as logging
from designate.pool_manager import service as pool_manager_service from designate.pool_manager import service as pool_manager_service
@ -30,7 +30,7 @@ CONF.import_opt('workers', 'designate.pool_manager',
def main(): def main():
utils.read_config('designate', sys.argv) utils.read_config('designate', sys.argv)
logging.setup('designate') logging.setup(CONF, 'designate')
server = pool_manager_service.Service.create( server = pool_manager_service.Service.create(
binary='designate-pool-manager') binary='designate-pool-manager')

View File

@ -16,8 +16,8 @@
import sys import sys
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import service from designate import service
from designate import utils from designate import utils
from designate.sink import service as sink_service from designate.sink import service as sink_service
@ -29,7 +29,7 @@ CONF.import_opt('workers', 'designate.sink', group='service:sink')
def main(): def main():
utils.read_config('designate', sys.argv) utils.read_config('designate', sys.argv)
logging.setup('designate') logging.setup(CONF, 'designate')
server = sink_service.Service() server = sink_service.Service()
service.serve(server, workers=CONF['service:sink'].workers) service.serve(server, workers=CONF['service:sink'].workers)

View File

@ -17,9 +17,9 @@ import itertools
import copy import copy
from oslo_context import context from oslo_context import context
from oslo_log import log as logging
from designate.openstack.common import local from designate.openstack.common import local
from designate.openstack.common import log as logging
from designate import policy from designate import policy

View File

@ -17,8 +17,8 @@ import os
from migrate.versioning import api as versioning_api from migrate.versioning import api as versioning_api
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.manage import base from designate.manage import base
from designate.sqlalchemy import utils from designate.sqlalchemy import utils

View File

@ -17,8 +17,8 @@ import os
from migrate.versioning import api as versioning_api from migrate.versioning import api as versioning_api
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.manage import base from designate.manage import base
from designate.sqlalchemy import utils from designate.sqlalchemy import utils

View File

@ -18,8 +18,8 @@ import os
from migrate.versioning import api as versioning_api from migrate.versioning import api as versioning_api
from oslo.config import cfg from oslo.config import cfg
from oslo_db.sqlalchemy.migration_cli import manager as migration_manager from oslo_db.sqlalchemy.migration_cli import manager as migration_manager
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.manage import base from designate.manage import base
from designate import utils from designate import utils

View File

@ -16,11 +16,11 @@ import csv
import os import os
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate import rpc from designate import rpc
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LE from designate.i18n import _LE
from designate.manage import base from designate.manage import base

View File

@ -15,10 +15,10 @@
# under the License. # under the License.
import dns import dns
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate import storage from designate import storage
from designate.openstack.common import log as logging
from designate.i18n import _LE from designate.i18n import _LE

View File

@ -17,9 +17,9 @@ import time
import dns import dns
from oslo import messaging from oslo import messaging
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.pool_manager import rpcapi as pool_mngr_api from designate.pool_manager import rpcapi as pool_mngr_api
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LW from designate.i18n import _LW

View File

@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo import messaging from oslo import messaging
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate import rpc from designate import rpc

View File

@ -18,12 +18,12 @@ import struct
import dns import dns
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import service from designate import service
from designate.mdns import handler from designate.mdns import handler
from designate.mdns import middleware from designate.mdns import middleware
from designate.mdns import notify from designate.mdns import notify
from designate.openstack.common import log as logging
from designate.i18n import _LE from designate.i18n import _LE
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LW from designate.i18n import _LW

View File

@ -15,10 +15,10 @@
# under the License. # under the License.
from dns import reversename from dns import reversename
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate.plugin import DriverPlugin from designate.plugin import DriverPlugin
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,11 +15,12 @@
# under the License. # under the License.
import uuid import uuid
from designate.openstack.common import log from oslo_log import log as logging
from designate.network_api.base import NetworkAPI from designate.network_api.base import NetworkAPI
LOG = log.getLogger(__name__) LOG = logging.getLogger(__name__)
POOL = dict([(str(uuid.uuid4()), '192.168.2.%s' % i) for i in xrange(0, 254)]) POOL = dict([(str(uuid.uuid4()), '192.168.2.%s' % i) for i in xrange(0, 254)])
ALLOCATIONS = {} ALLOCATIONS = {}

View File

@ -20,9 +20,9 @@
from neutronclient.v2_0 import client as clientv20 from neutronclient.v2_0 import client as clientv20
from neutronclient.common import exceptions as neutron_exceptions from neutronclient.common import exceptions as neutron_exceptions
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate.openstack.common import log as logging
from designate.openstack.common import threadgroup from designate.openstack.common import threadgroup
from designate.i18n import _LW from designate.i18n import _LW
from designate.i18n import _LE from designate.i18n import _LE

View File

@ -17,9 +17,9 @@
import abc import abc
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate.openstack.common import log as logging
from designate.central import rpcapi as central_rpcapi from designate.central import rpcapi as central_rpcapi
from designate.context import DesignateContext from designate.context import DesignateContext
from designate.objects import Record from designate.objects import Record

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.notification_handler.base import BaseAddressHandler from designate.notification_handler.base import BaseAddressHandler

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.notification_handler.base import BaseAddressHandler from designate.notification_handler.base import BaseAddressHandler

View File

@ -17,8 +17,8 @@
# Copied: nova.notifications # Copied: nova.notifications
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import rpc from designate import rpc
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,8 +17,8 @@ import urlparse
import six import six
import jsonschema import jsonschema
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate.schema import validators from designate.schema import validators
from designate.schema import format from designate.schema import format

View File

@ -29,9 +29,9 @@ import eventlet
import eventlet.backdoor import eventlet.backdoor
import greenlet import greenlet
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common._i18n import _LI from designate.openstack.common._i18n import _LI
from designate.openstack.common import log as logging
help_for_backdoor_port = ( help_for_backdoor_port = (
"Acceptable values are 0, <port>, and <start>:<end>, where 0 results " "Acceptable values are 0, <port>, and <start>:<end>, where 0 results "

View File

@ -1,718 +0,0 @@
# Copyright 2011 OpenStack Foundation.
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# 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
#
# 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.
"""OpenStack logging handler.
This module adds to logging functionality by adding the option to specify
a context object when calling the various log methods. If the context object
is not specified, default formatting is used. Additionally, an instance uuid
may be passed as part of the log message, which is intended to make it easier
for admins to find messages related to a specific instance.
It also allows setting of formatting information through conf.
"""
import copy
import inspect
import itertools
import logging
import logging.config
import logging.handlers
import os
import socket
import sys
import traceback
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo.utils import importutils
import six
from six import moves
_PY26 = sys.version_info[0:2] == (2, 6)
from designate.openstack.common._i18n import _
from designate.openstack.common import local
_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
common_cli_opts = [
cfg.BoolOpt('debug',
short='d',
default=False,
help='Print debugging output (set logging level to '
'DEBUG instead of default WARNING level).'),
cfg.BoolOpt('verbose',
short='v',
default=False,
help='Print more verbose output (set logging level to '
'INFO instead of default WARNING level).'),
]
logging_cli_opts = [
cfg.StrOpt('log-config-append',
metavar='PATH',
deprecated_name='log-config',
help='The name of a logging configuration file. This file '
'is appended to any existing logging configuration '
'files. For details about logging configuration files, '
'see the Python logging module documentation.'),
cfg.StrOpt('log-format',
metavar='FORMAT',
help='DEPRECATED. '
'A logging.Formatter log message format string which may '
'use any of the available logging.LogRecord attributes. '
'This option is deprecated. Please use '
'logging_context_format_string and '
'logging_default_format_string instead.'),
cfg.StrOpt('log-date-format',
default=_DEFAULT_LOG_DATE_FORMAT,
metavar='DATE_FORMAT',
help='Format string for %%(asctime)s in log records. '
'Default: %(default)s .'),
cfg.StrOpt('log-file',
metavar='PATH',
deprecated_name='logfile',
help='(Optional) Name of log file to output to. '
'If no default is set, logging will go to stdout.'),
cfg.StrOpt('log-dir',
deprecated_name='logdir',
help='(Optional) The base directory used for relative '
'--log-file paths.'),
cfg.BoolOpt('use-syslog',
default=False,
help='Use syslog for logging. '
'Existing syslog format is DEPRECATED during I, '
'and will change in J to honor RFC5424.'),
cfg.BoolOpt('use-syslog-rfc-format',
# TODO(bogdando) remove or use True after existing
# syslog format deprecation in J
default=False,
help='(Optional) Enables or disables syslog rfc5424 format '
'for logging. If enabled, prefixes the MSG part of the '
'syslog message with APP-NAME (RFC5424). The '
'format without the APP-NAME is deprecated in I, '
'and will be removed in J.'),
cfg.StrOpt('syslog-log-facility',
default='LOG_USER',
help='Syslog facility to receive log lines.')
]
generic_log_opts = [
cfg.BoolOpt('use_stderr',
default=True,
help='Log output to standard error.')
]
DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'boto=WARN',
'qpid=WARN', 'sqlalchemy=WARN', 'suds=INFO',
'oslo.messaging=INFO', 'iso8601=WARN',
'requests.packages.urllib3.connectionpool=WARN',
'urllib3.connectionpool=WARN', 'websocket=WARN',
"keystonemiddleware=WARN", "routes.middleware=WARN",
"stevedore=WARN"]
log_opts = [
cfg.StrOpt('logging_context_format_string',
default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
'%(name)s [%(request_id)s %(user_identity)s] '
'%(instance)s%(message)s',
help='Format string to use for log messages with context.'),
cfg.StrOpt('logging_default_format_string',
default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
'%(name)s [-] %(instance)s%(message)s',
help='Format string to use for log messages without context.'),
cfg.StrOpt('logging_debug_format_suffix',
default='%(funcName)s %(pathname)s:%(lineno)d',
help='Data to append to log format when level is DEBUG.'),
cfg.StrOpt('logging_exception_prefix',
default='%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s '
'%(instance)s',
help='Prefix each line of exception output with this format.'),
cfg.ListOpt('default_log_levels',
default=DEFAULT_LOG_LEVELS,
help='List of logger=LEVEL pairs.'),
cfg.BoolOpt('publish_errors',
default=False,
help='Enables or disables publication of error events.'),
cfg.BoolOpt('fatal_deprecations',
default=False,
help='Enables or disables fatal status of deprecations.'),
# NOTE(mikal): there are two options here because sometimes we are handed
# a full instance (and could include more information), and other times we
# are just handed a UUID for the instance.
cfg.StrOpt('instance_format',
default='[instance: %(uuid)s] ',
help='The format for an instance that is passed with the log '
'message.'),
cfg.StrOpt('instance_uuid_format',
default='[instance: %(uuid)s] ',
help='The format for an instance UUID that is passed with the '
'log message.'),
]
CONF = cfg.CONF
CONF.register_cli_opts(common_cli_opts)
CONF.register_cli_opts(logging_cli_opts)
CONF.register_opts(generic_log_opts)
CONF.register_opts(log_opts)
def list_opts():
"""Entry point for oslo.config-generator."""
return [(None, copy.deepcopy(common_cli_opts)),
(None, copy.deepcopy(logging_cli_opts)),
(None, copy.deepcopy(generic_log_opts)),
(None, copy.deepcopy(log_opts)),
]
# our new audit level
# NOTE(jkoelker) Since we synthesized an audit level, make the logging
# module aware of it so it acts like other levels.
logging.AUDIT = logging.INFO + 1
logging.addLevelName(logging.AUDIT, 'AUDIT')
try:
NullHandler = logging.NullHandler
except AttributeError: # NOTE(jkoelker) NullHandler added in Python 2.7
class NullHandler(logging.Handler):
def handle(self, record):
pass
def emit(self, record):
pass
def createLock(self):
self.lock = None
def _dictify_context(context):
if context is None:
return None
if not isinstance(context, dict) and getattr(context, 'to_dict', None):
context = context.to_dict()
return context
def _get_binary_name():
return os.path.basename(inspect.stack()[-1][1])
def _get_log_file_path(binary=None):
logfile = CONF.log_file
logdir = CONF.log_dir
if logfile and not logdir:
return logfile
if logfile and logdir:
return os.path.join(logdir, logfile)
if logdir:
binary = binary or _get_binary_name()
return '%s.log' % (os.path.join(logdir, binary),)
return None
class BaseLoggerAdapter(logging.LoggerAdapter):
def audit(self, msg, *args, **kwargs):
self.log(logging.AUDIT, msg, *args, **kwargs)
def isEnabledFor(self, level):
if _PY26:
# This method was added in python 2.7 (and it does the exact
# same logic, so we need to do the exact same logic so that
# python 2.6 has this capability as well).
return self.logger.isEnabledFor(level)
else:
return super(BaseLoggerAdapter, self).isEnabledFor(level)
class LazyAdapter(BaseLoggerAdapter):
def __init__(self, name='unknown', version='unknown'):
self._logger = None
self.extra = {}
self.name = name
self.version = version
@property
def logger(self):
if not self._logger:
self._logger = getLogger(self.name, self.version)
if six.PY3:
# In Python 3, the code fails because the 'manager' attribute
# cannot be found when using a LoggerAdapter as the
# underlying logger. Work around this issue.
self._logger.manager = self._logger.logger.manager
return self._logger
class ContextAdapter(BaseLoggerAdapter):
warn = logging.LoggerAdapter.warning
def __init__(self, logger, project_name, version_string):
self.logger = logger
self.project = project_name
self.version = version_string
self._deprecated_messages_sent = dict()
@property
def handlers(self):
return self.logger.handlers
def deprecated(self, msg, *args, **kwargs):
"""Call this method when a deprecated feature is used.
If the system is configured for fatal deprecations then the message
is logged at the 'critical' level and :class:`DeprecatedConfig` will
be raised.
Otherwise, the message will be logged (once) at the 'warn' level.
:raises: :class:`DeprecatedConfig` if the system is configured for
fatal deprecations.
"""
stdmsg = _("Deprecated: %s") % msg
if CONF.fatal_deprecations:
self.critical(stdmsg, *args, **kwargs)
raise DeprecatedConfig(msg=stdmsg)
# Using a list because a tuple with dict can't be stored in a set.
sent_args = self._deprecated_messages_sent.setdefault(msg, list())
if args in sent_args:
# Already logged this message, so don't log it again.
return
sent_args.append(args)
self.warn(stdmsg, *args, **kwargs)
def process(self, msg, kwargs):
# NOTE(jecarey): If msg is not unicode, coerce it into unicode
# before it can get to the python logging and
# possibly cause string encoding trouble
if not isinstance(msg, six.text_type):
msg = six.text_type(msg)
if 'extra' not in kwargs:
kwargs['extra'] = {}
extra = kwargs['extra']
context = kwargs.pop('context', None)
if not context:
context = getattr(local.store, 'context', None)
if context:
extra.update(_dictify_context(context))
instance = kwargs.pop('instance', None)
instance_uuid = (extra.get('instance_uuid') or
kwargs.pop('instance_uuid', None))
instance_extra = ''
if instance:
instance_extra = CONF.instance_format % instance
elif instance_uuid:
instance_extra = (CONF.instance_uuid_format
% {'uuid': instance_uuid})
extra['instance'] = instance_extra
extra.setdefault('user_identity', kwargs.pop('user_identity', None))
extra['project'] = self.project
extra['version'] = self.version
extra['extra'] = extra.copy()
return msg, kwargs
class JSONFormatter(logging.Formatter):
def __init__(self, fmt=None, datefmt=None):
# NOTE(jkoelker) we ignore the fmt argument, but its still there
# since logging.config.fileConfig passes it.
self.datefmt = datefmt
def formatException(self, ei, strip_newlines=True):
lines = traceback.format_exception(*ei)
if strip_newlines:
lines = [moves.filter(
lambda x: x,
line.rstrip().splitlines()) for line in lines]
lines = list(itertools.chain(*lines))
return lines
def format(self, record):
message = {'message': record.getMessage(),
'asctime': self.formatTime(record, self.datefmt),
'name': record.name,
'msg': record.msg,
'args': record.args,
'levelname': record.levelname,
'levelno': record.levelno,
'pathname': record.pathname,
'filename': record.filename,
'module': record.module,
'lineno': record.lineno,
'funcname': record.funcName,
'created': record.created,
'msecs': record.msecs,
'relative_created': record.relativeCreated,
'thread': record.thread,
'thread_name': record.threadName,
'process_name': record.processName,
'process': record.process,
'traceback': None}
if hasattr(record, 'extra'):
message['extra'] = record.extra
if record.exc_info:
message['traceback'] = self.formatException(record.exc_info)
return jsonutils.dumps(message)
def _create_logging_excepthook(product_name):
def logging_excepthook(exc_type, value, tb):
extra = {'exc_info': (exc_type, value, tb)}
getLogger(product_name).critical(
"".join(traceback.format_exception_only(exc_type, value)),
**extra)
return logging_excepthook
class LogConfigError(Exception):
message = _('Error loading logging config %(log_config)s: %(err_msg)s')
def __init__(self, log_config, err_msg):
self.log_config = log_config
self.err_msg = err_msg
def __str__(self):
return self.message % dict(log_config=self.log_config,
err_msg=self.err_msg)
def _load_log_config(log_config_append):
try:
logging.config.fileConfig(log_config_append,
disable_existing_loggers=False)
except (moves.configparser.Error, KeyError) as exc:
raise LogConfigError(log_config_append, six.text_type(exc))
def setup(product_name, version='unknown'):
"""Setup logging."""
if CONF.log_config_append:
_load_log_config(CONF.log_config_append)
else:
_setup_logging_from_conf(product_name, version)
sys.excepthook = _create_logging_excepthook(product_name)
def set_defaults(logging_context_format_string=None,
default_log_levels=None):
# Just in case the caller is not setting the
# default_log_level. This is insurance because
# we introduced the default_log_level parameter
# later in a backwards in-compatible change
if default_log_levels is not None:
cfg.set_defaults(
log_opts,
default_log_levels=default_log_levels)
if logging_context_format_string is not None:
cfg.set_defaults(
log_opts,
logging_context_format_string=logging_context_format_string)
def _find_facility_from_conf():
facility_names = logging.handlers.SysLogHandler.facility_names
facility = getattr(logging.handlers.SysLogHandler,
CONF.syslog_log_facility,
None)
if facility is None and CONF.syslog_log_facility in facility_names:
facility = facility_names.get(CONF.syslog_log_facility)
if facility is None:
valid_facilities = facility_names.keys()
consts = ['LOG_AUTH', 'LOG_AUTHPRIV', 'LOG_CRON', 'LOG_DAEMON',
'LOG_FTP', 'LOG_KERN', 'LOG_LPR', 'LOG_MAIL', 'LOG_NEWS',
'LOG_AUTH', 'LOG_SYSLOG', 'LOG_USER', 'LOG_UUCP',
'LOG_LOCAL0', 'LOG_LOCAL1', 'LOG_LOCAL2', 'LOG_LOCAL3',
'LOG_LOCAL4', 'LOG_LOCAL5', 'LOG_LOCAL6', 'LOG_LOCAL7']
valid_facilities.extend(consts)
raise TypeError(_('syslog facility must be one of: %s') %
', '.join("'%s'" % fac
for fac in valid_facilities))
return facility
class RFCSysLogHandler(logging.handlers.SysLogHandler):
def __init__(self, *args, **kwargs):
self.binary_name = _get_binary_name()
# Do not use super() unless type(logging.handlers.SysLogHandler)
# is 'type' (Python 2.7).
# Use old style calls, if the type is 'classobj' (Python 2.6)
logging.handlers.SysLogHandler.__init__(self, *args, **kwargs)
def format(self, record):
# Do not use super() unless type(logging.handlers.SysLogHandler)
# is 'type' (Python 2.7).
# Use old style calls, if the type is 'classobj' (Python 2.6)
msg = logging.handlers.SysLogHandler.format(self, record)
msg = self.binary_name + ' ' + msg
return msg
def _setup_logging_from_conf(project, version):
log_root = getLogger(None).logger
for handler in log_root.handlers:
log_root.removeHandler(handler)
logpath = _get_log_file_path()
if logpath:
filelog = logging.handlers.WatchedFileHandler(logpath)
log_root.addHandler(filelog)
if CONF.use_stderr:
streamlog = ColorHandler()
log_root.addHandler(streamlog)
elif not logpath:
# pass sys.stdout as a positional argument
# python2.6 calls the argument strm, in 2.7 it's stream
streamlog = logging.StreamHandler(sys.stdout)
log_root.addHandler(streamlog)
if CONF.publish_errors:
handler = importutils.import_object(
"oslo.messaging.notify.log_handler.PublishErrorsHandler",
logging.ERROR)
log_root.addHandler(handler)
datefmt = CONF.log_date_format
for handler in log_root.handlers:
# NOTE(alaski): CONF.log_format overrides everything currently. This
# should be deprecated in favor of context aware formatting.
if CONF.log_format:
handler.setFormatter(logging.Formatter(fmt=CONF.log_format,
datefmt=datefmt))
log_root.info('Deprecated: log_format is now deprecated and will '
'be removed in the next release')
else:
handler.setFormatter(ContextFormatter(project=project,
version=version,
datefmt=datefmt))
if CONF.debug:
log_root.setLevel(logging.DEBUG)
elif CONF.verbose:
log_root.setLevel(logging.INFO)
else:
log_root.setLevel(logging.WARNING)
for pair in CONF.default_log_levels:
mod, _sep, level_name = pair.partition('=')
logger = logging.getLogger(mod)
# NOTE(AAzza) in python2.6 Logger.setLevel doesn't convert string name
# to integer code.
if sys.version_info < (2, 7):
level = logging.getLevelName(level_name)
logger.setLevel(level)
else:
logger.setLevel(level_name)
if CONF.use_syslog:
try:
facility = _find_facility_from_conf()
# TODO(bogdando) use the format provided by RFCSysLogHandler
# after existing syslog format deprecation in J
if CONF.use_syslog_rfc_format:
syslog = RFCSysLogHandler(address='/dev/log',
facility=facility)
else:
syslog = logging.handlers.SysLogHandler(address='/dev/log',
facility=facility)
log_root.addHandler(syslog)
except socket.error:
log_root.error('Unable to add syslog handler. Verify that syslog '
'is running.')
_loggers = {}
def getLogger(name='unknown', version='unknown'):
if name not in _loggers:
_loggers[name] = ContextAdapter(logging.getLogger(name),
name,
version)
return _loggers[name]
def getLazyLogger(name='unknown', version='unknown'):
"""Returns lazy logger.
Creates a pass-through logger that does not create the real logger
until it is really needed and delegates all calls to the real logger
once it is created.
"""
return LazyAdapter(name, version)
class WritableLogger(object):
"""A thin wrapper that responds to `write` and logs."""
def __init__(self, logger, level=logging.INFO):
self.logger = logger
self.level = level
def write(self, msg):
self.logger.log(self.level, msg.rstrip())
class ContextFormatter(logging.Formatter):
"""A context.RequestContext aware formatter configured through flags.
The flags used to set format strings are: logging_context_format_string
and logging_default_format_string. You can also specify
logging_debug_format_suffix to append extra formatting if the log level is
debug.
For information about what variables are available for the formatter see:
http://docs.python.org/library/logging.html#formatter
If available, uses the context value stored in TLS - local.store.context
"""
def __init__(self, *args, **kwargs):
"""Initialize ContextFormatter instance
Takes additional keyword arguments which can be used in the message
format string.
:keyword project: project name
:type project: string
:keyword version: project version
:type version: string
"""
self.project = kwargs.pop('project', 'unknown')
self.version = kwargs.pop('version', 'unknown')
logging.Formatter.__init__(self, *args, **kwargs)
def format(self, record):
"""Uses contextstring if request_id is set, otherwise default."""
# NOTE(jecarey): If msg is not unicode, coerce it into unicode
# before it can get to the python logging and
# possibly cause string encoding trouble
if not isinstance(record.msg, six.text_type):
record.msg = six.text_type(record.msg)
# store project info
record.project = self.project
record.version = self.version
# store request info
context = getattr(local.store, 'context', None)
if context:
d = _dictify_context(context)
for k, v in d.items():
setattr(record, k, v)
# NOTE(sdague): default the fancier formatting params
# to an empty string so we don't throw an exception if
# they get used
for key in ('instance', 'color', 'user_identity'):
if key not in record.__dict__:
record.__dict__[key] = ''
if record.__dict__.get('request_id'):
fmt = CONF.logging_context_format_string
else:
fmt = CONF.logging_default_format_string
if (record.levelno == logging.DEBUG and
CONF.logging_debug_format_suffix):
fmt += " " + CONF.logging_debug_format_suffix
if sys.version_info < (3, 2):
self._fmt = fmt
else:
self._style = logging.PercentStyle(fmt)
self._fmt = self._style._fmt
# Cache this on the record, Logger will respect our formatted copy
if record.exc_info:
record.exc_text = self.formatException(record.exc_info, record)
return logging.Formatter.format(self, record)
def formatException(self, exc_info, record=None):
"""Format exception output with CONF.logging_exception_prefix."""
if not record:
return logging.Formatter.formatException(self, exc_info)
stringbuffer = moves.StringIO()
traceback.print_exception(exc_info[0], exc_info[1], exc_info[2],
None, stringbuffer)
lines = stringbuffer.getvalue().split('\n')
stringbuffer.close()
if CONF.logging_exception_prefix.find('%(asctime)') != -1:
record.asctime = self.formatTime(record, self.datefmt)
formatted_lines = []
for line in lines:
pl = CONF.logging_exception_prefix % record.__dict__
fl = '%s%s' % (pl, line)
formatted_lines.append(fl)
return '\n'.join(formatted_lines)
class ColorHandler(logging.StreamHandler):
LEVEL_COLORS = {
logging.DEBUG: '\033[00;32m', # GREEN
logging.INFO: '\033[00;36m', # CYAN
logging.AUDIT: '\033[01;36m', # BOLD CYAN
logging.WARN: '\033[01;33m', # BOLD YELLOW
logging.ERROR: '\033[01;31m', # BOLD RED
logging.CRITICAL: '\033[01;31m', # BOLD RED
}
def format(self, record):
record.color = self.LEVEL_COLORS[record.levelno]
return logging.StreamHandler.format(self, record)
class DeprecatedConfig(Exception):
message = _("Fatal call to deprecated config: %(msg)s")
def __init__(self, msg):
super(Exception, self).__init__(self.message % dict(msg=msg))

View File

@ -20,9 +20,9 @@ import time
from eventlet import event from eventlet import event
from eventlet import greenthread from eventlet import greenthread
from oslo_log import log as logging
from designate.openstack.common._i18n import _LE, _LW from designate.openstack.common._i18n import _LE, _LW
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -95,6 +95,7 @@ import os
import re import re
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo.serialization import jsonutils from oslo.serialization import jsonutils
import six import six
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
@ -102,7 +103,6 @@ import six.moves.urllib.request as urlrequest
from designate.openstack.common import fileutils from designate.openstack.common import fileutils
from designate.openstack.common._i18n import _, _LE, _LI from designate.openstack.common._i18n import _, _LE, _LI
from designate.openstack.common import log as logging
policy_opts = [ policy_opts = [

View File

@ -36,10 +36,11 @@ except ImportError:
import eventlet import eventlet
from eventlet import event from eventlet import event
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import eventlet_backdoor from designate.openstack.common import eventlet_backdoor
from designate.openstack.common._i18n import _LE, _LI, _LW from designate.openstack.common._i18n import _LE, _LI, _LW
from designate.openstack.common import log as logging
from designate.openstack.common import systemd from designate.openstack.common import systemd
from designate.openstack.common import threadgroup from designate.openstack.common import threadgroup

View File

@ -20,7 +20,7 @@ import os
import socket import socket
import sys import sys
from designate.openstack.common import log as logging from oslo_log import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,8 +15,8 @@ import threading
import eventlet import eventlet
from eventlet import greenpool from eventlet import greenpool
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.openstack.common import loopingcall from designate.openstack.common import loopingcall

View File

@ -20,11 +20,11 @@ Helpers for comparing version strings.
import functools import functools
import inspect import inspect
from oslo_log import log as logging
import pkg_resources import pkg_resources
import six import six
from designate.openstack.common._i18n import _ from designate.openstack.common._i18n import _
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -28,6 +28,8 @@ import time
import eventlet.wsgi import eventlet.wsgi
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo_log import loggers
from oslo.serialization import jsonutils from oslo.serialization import jsonutils
import routes import routes
import routes.middleware import routes.middleware
@ -37,7 +39,6 @@ from xml.dom import minidom
from xml.parsers import expat from xml.parsers import expat
from designate.i18n import _ from designate.i18n import _
from designate.openstack.common import log as logging
from designate.openstack.common import service from designate.openstack.common import service
from designate.openstack.common import sslutils from designate.openstack.common import sslutils
from designate.openstack.deprecated import exception from designate.openstack.deprecated import exception
@ -158,7 +159,7 @@ class Service(service.Service):
eventlet.wsgi.server(socket, eventlet.wsgi.server(socket,
application, application,
custom_pool=self.tg.pool, custom_pool=self.tg.pool,
log=logging.WritableLogger(logger)) log=loggers.WritableLogger(logger))
class Middleware(object): class Middleware(object):

View File

@ -20,8 +20,7 @@ from stevedore import driver
from stevedore import enabled from stevedore import enabled
from stevedore import extension from stevedore import extension
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.openstack.common import policy from designate.openstack.common import policy
from designate.i18n import _ from designate.i18n import _
from designate.i18n import _LI from designate.i18n import _LI

View File

@ -13,7 +13,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate.openstack.common import log as logging from oslo_log import log as logging
from designate.pool_manager.cache.base import PoolManagerCache from designate.pool_manager.cache.base import PoolManagerCache
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,8 +15,8 @@
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_db import options from oslo_db import options
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import objects from designate import objects
from designate.pool_manager.cache import base as cache_base from designate.pool_manager.cache import base as cache_base

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from oslo import messaging from oslo import messaging
from designate.openstack.common import log as logging
from designate.i18n import _LI from designate.i18n import _LI
from designate import rpc from designate import rpc

View File

@ -18,6 +18,7 @@ from decimal import Decimal
from oslo.config import cfg from oslo.config import cfg
from oslo import messaging from oslo import messaging
from oslo_log import log as logging
from designate import backend from designate import backend
from designate import exceptions from designate import exceptions
@ -29,7 +30,6 @@ from designate.context import DesignateContext
from designate.i18n import _LE from designate.i18n import _LE
from designate.i18n import _LI from designate.i18n import _LI
from designate.i18n import _LW from designate.i18n import _LW
from designate.openstack.common import log as logging
from designate.pool_manager import cache from designate.pool_manager import cache

View File

@ -14,8 +14,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate.openstack.common import log as logging
from designate.quota.base import Quota from designate.quota.base import Quota

View File

@ -13,7 +13,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate.openstack.common import log as logging from oslo_log import log as logging
from designate.quota.base import Quota from designate.quota.base import Quota
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,11 +14,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate import storage from designate import storage
from designate import objects from designate import objects
from designate.openstack.common import log as logging
from designate.quota.base import Quota from designate.quota.base import Quota

View File

@ -13,7 +13,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from designate.openstack.common import log as logging from oslo_log import log as logging
from designate import exceptions from designate import exceptions
from designate import utils from designate import utils
from designate.schema import validators from designate.schema import validators

View File

@ -18,8 +18,7 @@ import re
import jsonschema import jsonschema
from jsonschema import compat from jsonschema import compat
import netaddr import netaddr
from oslo_log import log as logging
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

Some files were not shown because too many files have changed in this diff Show More