From 1bc87fd868ad6138795b1b06e5fdef42ebe78480 Mon Sep 17 00:00:00 2001 From: loooosy Date: Fri, 24 Mar 2017 14:51:13 +0800 Subject: [PATCH] Remove log translations Log messages are no longer being translated. This removes all use of the _LE, _LI, and _LW translation markers to simplify logging and to avoid confusion with new contributions. See: http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html Change-Id: I2e7d8d7643fe6598b3c75c48a801b8d71e5db038 --- oslo_privsep/_i18n.py | 10 ---------- oslo_privsep/daemon.py | 29 ++++++++++++++--------------- oslo_privsep/priv_context.py | 8 ++++---- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/oslo_privsep/_i18n.py b/oslo_privsep/_i18n.py index 795cd56..0aa541f 100644 --- a/oslo_privsep/_i18n.py +++ b/oslo_privsep/_i18n.py @@ -29,13 +29,3 @@ _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 diff --git a/oslo_privsep/daemon.py b/oslo_privsep/daemon.py index 196c8d5..38e7cb9 100644 --- a/oslo_privsep/daemon.py +++ b/oslo_privsep/daemon.py @@ -65,9 +65,9 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils +from oslo_privsep._i18n import _ from oslo_privsep import capabilities from oslo_privsep import comm -from oslo_privsep._i18n import _, _LE, _LI, _LW LOG = logging.getLogger(__name__) @@ -181,8 +181,7 @@ class _ClientChannel(comm.ClientChannel): reply = self.send_recv((Message.PING.value,)) success = reply[0] == Message.PONG except Exception as e: - LOG.exception( - _LE('Error while sending initial PING to privsep: %s'), e) + LOG.exception('Error while sending initial PING to privsep: %s', e) success = False if not success: msg = _('Privsep daemon failed to start') @@ -211,8 +210,8 @@ class _ClientChannel(comm.ClientChannel): if LOG.isEnabledFor(record.levelno): LOG.logger.handle(record) else: - LOG.warning(_LW('Ignoring unexpected OOB message from privileged ' - 'process: %r'), msg) + LOG.warning('Ignoring unexpected OOB message from privileged ' + 'process: %r', msg) def fdopen(fd, *args, **kwargs): @@ -319,14 +318,14 @@ class RootwrapClientChannel(_ClientChannel): listen_sock.listen(1) cmd = context.helper_command(sockpath) - LOG.info(_LI('Running privsep helper: %s'), cmd) + LOG.info('Running privsep helper: %s', cmd) proc = subprocess.Popen(cmd, shell=False, stderr=_fd_logger()) if proc.wait() != 0: - msg = (_LE('privsep helper command exited non-zero (%s)') % + msg = ('privsep helper command exited non-zero (%s)' % proc.returncode) LOG.critical(msg) raise FailedToDropPrivileges(msg) - LOG.info(_LI('Spawned new privsep daemon via rootwrap')) + LOG.info('Spawned new privsep daemon via rootwrap') sock, _addr = listen_sock.accept() LOG.debug('Accepted privsep connection to %s', sockpath) @@ -391,7 +390,7 @@ class Daemon(object): finally: capabilities.set_keepcaps(False) - LOG.info(_LI('privsep process running with uid/gid: %(uid)s/%(gid)s'), + LOG.info('privsep process running with uid/gid: %(uid)s/%(gid)s', {'uid': os.getuid(), 'gid': os.getgid()}) capabilities.drop_all_caps_except(self.caps, self.caps, []) @@ -406,8 +405,8 @@ class Daemon(object): eff, prm, inh = capabilities.get_caps() LOG.info( - _LI('privsep process running with capabilities ' - '(eff/prm/inh): %(eff)s/%(prm)s/%(inh)s'), + 'privsep process running with capabilities ' + '(eff/prm/inh): %(eff)s/%(prm)s/%(inh)s', { 'eff': fmt_caps(eff), 'prm': fmt_caps(prm), @@ -433,7 +432,7 @@ class Daemon(object): def loop(self): """Main body of daemon request loop""" - LOG.info(_LI('privsep daemon running as pid %s'), os.getpid()) + LOG.info('privsep daemon running as pid %s', os.getpid()) # We *are* this context now - any calls through it should be # executed locally. @@ -481,8 +480,8 @@ def helper_main(): context = importutils.import_class(cfg.CONF.privsep_context) from oslo_privsep import priv_context # Avoid circular import if not isinstance(context, priv_context.PrivContext): - LOG.fatal(_LE('--privsep_context must be the (python) name of a ' - 'PrivContext object')) + LOG.fatal('--privsep_context must be the (python) name of a ' + 'PrivContext object') sock = socket.socket(socket.AF_UNIX) sock.connect(cfg.CONF.privsep_sock_path) @@ -503,7 +502,7 @@ def helper_main(): # Channel is set up now, so move to in-band logging replace_logging(PrivsepLogHandler(channel)) - LOG.info(_LI('privsep daemon starting')) + LOG.info('privsep daemon starting') try: Daemon(channel, context).run() diff --git a/oslo_privsep/priv_context.py b/oslo_privsep/priv_context.py index 12cf8cd..e3f1b2a 100644 --- a/oslo_privsep/priv_context.py +++ b/oslo_privsep/priv_context.py @@ -23,9 +23,9 @@ from oslo_config import cfg from oslo_config import types from oslo_utils import importutils +from oslo_privsep._i18n import _ from oslo_privsep import capabilities from oslo_privsep import daemon -from oslo_privsep._i18n import _, _LW, _LE LOG = logging.getLogger(__name__) @@ -172,8 +172,8 @@ class PrivContext(object): def set_client_mode(self, enabled): if enabled and sys.platform == 'win32': raise RuntimeError( - _LE("Enabling the client_mode is not currently " - "supported on Windows.")) + "Enabling the client_mode is not currently " + "supported on Windows.") self.client_mode = enabled def entrypoint(self, func): @@ -208,7 +208,7 @@ class PrivContext(object): def start(self, method=Method.ROOTWRAP): if self.channel is not None: - LOG.warning(_LW('privsep daemon already running')) + LOG.warning('privsep daemon already running') return if method is Method.ROOTWRAP: