From 0267193cf27978e7fb1d78545d018288b3e3f518 Mon Sep 17 00:00:00 2001 From: liusheng Date: Mon, 25 Apr 2016 11:39:47 +0800 Subject: [PATCH] Replace logging with oslo_log If we use logging lib to initialize a logger, the logger won't be applied the oslo_log config options. Change-Id: Ib6bc686f4296cc335aa5abcc47f266a237d8688c --- ceilometer/api/app.py | 3 +-- ceilometer/cmd/storage.py | 5 ++--- ceilometer/event/endpoint.py | 5 ++--- ceilometer/nova_client.py | 5 ++--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ceilometer/api/app.py b/ceilometer/api/app.py index cc33d8b9..adde6d16 100644 --- a/ceilometer/api/app.py +++ b/ceilometer/api/app.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import logging import os from oslo_config import cfg @@ -108,7 +107,7 @@ def build_server(): LOG.info(_LI('Starting server in PID %s') % os.getpid()) LOG.info(_LI("Configuration:")) - cfg.CONF.log_opt_values(LOG, logging.INFO) + cfg.CONF.log_opt_values(LOG, log.INFO) if host == '0.0.0.0': LOG.info(_LI( diff --git a/ceilometer/cmd/storage.py b/ceilometer/cmd/storage.py index 752ea63f..977b1929 100644 --- a/ceilometer/cmd/storage.py +++ b/ceilometer/cmd/storage.py @@ -14,16 +14,15 @@ # License for the specific language governing permissions and limitations # under the License. -import logging - from oslo_config import cfg +from oslo_log import log from ceilometer.i18n import _LI from ceilometer import service from ceilometer import storage -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) def dbsync(): diff --git a/ceilometer/event/endpoint.py b/ceilometer/event/endpoint.py index 75b14ba1..bd78bc91 100644 --- a/ceilometer/event/endpoint.py +++ b/ceilometer/event/endpoint.py @@ -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 import oslo_messaging from stevedore import extension @@ -22,7 +21,7 @@ from ceilometer.event import converter as event_converter from ceilometer.i18n import _LE from ceilometer import messaging -LOG = logging.getLogger(__name__) +LOG = log.getLogger(__name__) class EventsNotificationEndpoint(object): diff --git a/ceilometer/nova_client.py b/ceilometer/nova_client.py index b28a9f01..eedfe592 100644 --- a/ceilometer/nova_client.py +++ b/ceilometer/nova_client.py @@ -12,7 +12,6 @@ # under the License. import functools -import logging import novaclient from novaclient import client as nova_client @@ -66,8 +65,8 @@ class Client(object): logger = None if cfg.CONF.nova_http_log_debug: - logger = logging.getLogger("novaclient-debug") - logger.setLevel(log.DEBUG) + logger = log.getLogger("novaclient-debug") + logger.logger.setLevel(log.DEBUG) self.nova_client = nova_client.Client( version=2,