Remove log translations and hacking

Log translation is no longer used, remove translate functions

Change-Id: Ibe205266debd6d39dab0a652a327ab19081ff27a
This commit is contained in:
Ngo Quoc Cuong 2017-05-23 16:12:26 +07:00
parent 32dacdca8b
commit 17aa1122da
3 changed files with 2 additions and 34 deletions

@ -32,16 +32,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 lazy_translation_enabled():
return _lazy.USE_LAZY

@ -21,7 +21,6 @@ from oslo_log import log
from oslo_utils import timeutils
import six
from watcher._i18n import _LW
from watcher.common import context as watcher_context
from watcher.common import scheduling
from watcher import notifications
@ -67,9 +66,8 @@ class APISchedulingService(scheduling.BackgroundSchedulerService):
elapsed = timeutils.delta_seconds(last_heartbeat, timeutils.utcnow())
is_up = abs(elapsed) <= CONF.service_down_time
if not is_up:
LOG.warning(_LW('Seems service %(name)s on host %(host)s is down. '
'Last heartbeat was %(lhb)s.'
'Elapsed time is %(el)s'),
LOG.warning('Seems service %(name)s on host %(host)s is down. '
'Last heartbeat was %(lhb)s. Elapsed time is %(el)s',
{'name': service.name,
'host': service.host,
'lhb': str(last_heartbeat), 'el': str(elapsed)})

@ -15,8 +15,6 @@
import os
import re
import pep8
def flake8ext(f):
"""Decorator to indicate flake8 extension.
@ -58,29 +56,12 @@ def _regex_for_level(level, hint):
}
log_translation_hint = re.compile(
'|'.join('(?:%s)' % _regex_for_level(level, hint)
for level, hint in _all_log_levels.items()))
log_warn = re.compile(
r"(.)*LOG\.(warn)\(\s*('|\"|_)")
unittest_imports_dot = re.compile(r"\bimport[\s]+unittest\b")
unittest_imports_from = re.compile(r"\bfrom[\s]+unittest\b")
@flake8ext
def validate_log_translations(logical_line, physical_line, filename):
# Translations are not required in the test directory
if "watcher/tests" in filename:
return
if pep8.noqa(physical_line):
return
msg = "N320: Log messages require translation hints!"
if log_translation_hint.match(logical_line):
yield (0, msg)
@flake8ext
def use_jsonutils(logical_line, filename):
msg = "N321: jsonutils.%(fun)s must be used instead of json.%(fun)s"
@ -291,7 +272,6 @@ def check_builtins_gettext(logical_line, tokens, filename, lines, noqa):
def factory(register):
register(validate_log_translations)
register(use_jsonutils)
register(check_assert_called_once_with)
register(no_translate_debug_logs)