diff --git a/gluon/_i18n.py b/gluon/_i18n.py index efe7e0c..9d5fb6a 100644 --- a/gluon/_i18n.py +++ b/gluon/_i18n.py @@ -27,16 +27,6 @@ _C = _translators.contextual_form # The plural translation function using the name "_P" _P = _translators.plural_form -# Translators for log levels. -# -# The abbreviated names are meant to reflect the usual use of a short -# name like '_'. The "L" is for "log" and the other letter comes from -# the level. -_LI = _translators.log_info -_LW = _translators.log_warning -_LE = _translators.log_error -_LC = _translators.log_critical - def get_available_languages(): return oslo_i18n.get_available_languages(DOMAIN) diff --git a/gluon/cmd/api.py b/gluon/cmd/api.py index 92bb7dc..969cd67 100644 --- a/gluon/cmd/api.py +++ b/gluon/cmd/api.py @@ -18,7 +18,7 @@ import sys from wsgiref import simple_server from oslo_config import cfg -from oslo_log._i18n import _LI +from oslo_log._i18n import _ from oslo_log import log as logging from gluon.api import app as api_app @@ -60,15 +60,15 @@ def main(): host, port = cfg.CONF.api.host, cfg.CONF.api.port srv = simple_server.make_server(host, port, app) - LOG.info(_LI('Starting server in PID %s') % os.getpid()) + LOG.info('Starting server in PID %s' % os.getpid()) LOG.debug("Configuration:") if host == '0.0.0.0': - LOG.info(_LI('serving on 0.0.0.0:%(port)s, ' - 'view at http://127.0.0.1:%(port)s') % + LOG.info(('serving on 0.0.0.0:%(port)s, ' + 'view at http://127.0.0.1:%(port)s') % dict(port=port)) else: - LOG.info(_LI('serving on http://%(host)s:%(port)s') % + LOG.info('serving on http://%(host)s:%(port)s' % dict(host=host, port=port)) start_sync_thread(etcd_host=cfg.CONF.api.etcd_host, etcd_port=cfg.CONF.api.etcd_port) diff --git a/gluon/common/exception.py b/gluon/common/exception.py index ee86bdd..a797819 100644 --- a/gluon/common/exception.py +++ b/gluon/common/exception.py @@ -25,7 +25,6 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_log._i18n import _ -from oslo_log._i18n import _LE LOG = logging.getLogger(__name__) CONF = cfg.CONF @@ -59,9 +58,9 @@ class GluonException(Exception): except Exception as e: # kwargs doesn't match a variable in the message # log the issue and the kwargs - LOG.exception(_LE('Exception in string format operation')) + LOG.exception('Exception in string format operation') for name, value in six.iteritems(kwargs): - LOG.error(_LE("%(name)s: %(value)s") % + LOG.error("%(name)s: %(value)s" % {'name': name, 'value': value}) try: if CONF.fatal_exception_format_errors: diff --git a/gluon/policy.py b/gluon/policy.py index 9bb69a1..ee21348 100644 --- a/gluon/policy.py +++ b/gluon/policy.py @@ -27,8 +27,6 @@ from oslo_utils import importutils from gluon import constants from gluon._i18n import _ -from gluon._i18n import _LE -from gluon._i18n import _LW from gluon.api import attributes from gluon.common import exception as g_exc @@ -119,8 +117,8 @@ def _build_subattr_match_rule(attr_name, attr, action, target): validate = attr['validate'] key = [k for k in validate.keys() if k.startswith('type:dict')] if not key: - LOG.warning(_LW("Unable to find data type descriptor " - "for attribute %s"), + LOG.warning(("Unable to find data type descriptor " + "for attribute %s"), attr_name) return data = validate[key[0]] @@ -278,8 +276,7 @@ class OwnerCheck(policy.Check): raise db_exc.RetryRequest(e) except Exception: with excutils.save_and_reraise_exception(): - LOG.exception(_LE('Policy check error while calling %s!'), - f) + LOG.exception('Policy check error while calling %s!', f) match = self.match % target if self.kind in creds: return match == six.text_type(creds[self.kind]) diff --git a/gluon/sync_etcd/thread.py b/gluon/sync_etcd/thread.py index 6a390f1..b134e9b 100644 --- a/gluon/sync_etcd/thread.py +++ b/gluon/sync_etcd/thread.py @@ -21,9 +21,7 @@ import threading import etcd from gluon.db import api as dbapi -from oslo_log._i18n import _LE -from oslo_log._i18n import _LI -from oslo_log._i18n import _LW +from oslo_log._i18n import _ from oslo_log import log as logging LOG = logging.getLogger(__name__) @@ -90,15 +88,15 @@ class SyncThread(threading.Thread): port_key = "/gluon/port/{0:s}".format(obj_key) self.etcd_client.delete(port_key) else: - LOG.error(_LE("Unkown operation in msg %s") % + LOG.error("Unkown operation in msg %s" % (msg["operation"])) except etcd.EtcdKeyNotFound: - LOG.warn(_LW("Unknown key %s") % obj_key) + LOG.warn("Unknown key %s" % obj_key) except Exception as e: print(e.__doc__) print(e.args[0]) LOG.error( - _LE("Error writing to etcd {doc}, {msg}").format( + "Error writing to etcd {doc}, {msg}".format( doc=e.__doc__, msg=e.args[0])) raise ValueError @@ -106,14 +104,14 @@ class SyncThread(threading.Thread): while 1: try: msg = self.input_q.get(True, 10.0) - LOG.info(_LI("SyncThread: received message %s ") % msg) + LOG.info("SyncThread: received message %s " % msg) self.proc_sync_msg(msg) except queue.Empty: LOG.debug("SyncThread: Queue timeout") except ValueError: - LOG.error(_LE("Error processing sync message")) + LOG.error("Error processing sync message") break - LOG.error(_LE("SyncThread exiting")) + LOG.error("SyncThread exiting") SyncData.sync_thread_running = False