From 5d461fae600e56066a71204f5316a01f1e4da981 Mon Sep 17 00:00:00 2001 From: loooosy Date: Tue, 21 Mar 2017 14:22:55 +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: I1201cab3686a3689c4d24d6da4ddef87fcd04f13 --- oslo_policy/_i18n.py | 10 ---------- oslo_policy/_parser.py | 7 +++---- oslo_policy/policy.py | 9 ++++----- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/oslo_policy/_i18n.py b/oslo_policy/_i18n.py index 87b3f5ba..7d9edf36 100644 --- a/oslo_policy/_i18n.py +++ b/oslo_policy/_i18n.py @@ -23,13 +23,3 @@ _translators = oslo_i18n.TranslatorFactory(domain='oslo_policy') # The primary translation function using the well-known name "_" _ = _translators.primary - -# 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_policy/_parser.py b/oslo_policy/_parser.py index 2225c2df..e85c81f3 100644 --- a/oslo_policy/_parser.py +++ b/oslo_policy/_parser.py @@ -21,7 +21,6 @@ import re import six from oslo_policy import _checks -from oslo_policy._i18n import _LE LOG = logging.getLogger(__name__) @@ -212,7 +211,7 @@ def _parse_check(rule): try: kind, match = rule.split(':', 1) except Exception: - LOG.exception(_LE('Failed to understand rule %s'), rule) + LOG.exception('Failed to understand rule %s', rule) # If the rule is invalid, we'll fail closed return _checks.FalseCheck() @@ -222,7 +221,7 @@ def _parse_check(rule): elif None in _checks.registered_checks: return _checks.registered_checks[None](kind, match) else: - LOG.error(_LE('No handler for matches of kind %s'), kind) + LOG.error('No handler for matches of kind %s', kind) return _checks.FalseCheck() @@ -338,7 +337,7 @@ def _parse_text_rule(rule): return state.result except ValueError: # Couldn't parse the rule - LOG.exception(_LE('Failed to understand rule %s'), rule) + LOG.exception('Failed to understand rule %s', rule) # Fail closed return _checks.FalseCheck() diff --git a/oslo_policy/policy.py b/oslo_policy/policy.py index 4a5a8796..211d6c9b 100644 --- a/oslo_policy/policy.py +++ b/oslo_policy/policy.py @@ -233,7 +233,6 @@ import yaml from oslo_policy import _cache_handler from oslo_policy import _checks from oslo_policy._i18n import _ -from oslo_policy._i18n import _LW from oslo_policy import _parser from oslo_policy import opts @@ -570,11 +569,11 @@ class Enforcer(object): violation = True if undefined_checks: - LOG.warning(_LW('Policies %(names)s reference a rule that is not ' - 'defined.'), {'names': undefined_checks}) + LOG.warning('Policies %(names)s reference a rule that is not ' + 'defined.', {'names': undefined_checks}) if cyclic_checks: - LOG.warning(_LW('Policies %(names)s are part of a cyclical ' - 'reference.'), {'names': cyclic_checks}) + LOG.warning('Policies %(names)s are part of a cyclical ' + 'reference.', {'names': cyclic_checks}) if raise_on_violation and violation: raise InvalidDefinitionError(undefined_checks + cyclic_checks)