Remove translation of log messages
The i18n team has decided not to translate the logs because it seems like it not very useful; operators prefer to have them in English so that they can search for those strings on the internet. Change-Id: I84b1a2397f424430ed332aa7d4d874379abd0357
This commit is contained in:
parent
8b0704e362
commit
1f1b7be594
|
@ -24,7 +24,7 @@ DOMAIN = 'syntribos'
|
|||
|
||||
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
|
||||
|
||||
# The primary translation function using the well-known name "_"
|
||||
# The translation function using the well-known name "_"
|
||||
_ = _translators.primary
|
||||
|
||||
# The contextual translation function using the name "_C"
|
||||
|
@ -35,16 +35,6 @@ _C = _translators.contextual_form
|
|||
# requires oslo.i18n >=2.1.0
|
||||
_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 enable_lazy():
|
||||
return oslo_i18n.enable_lazy()
|
||||
|
|
|
@ -22,8 +22,8 @@ from time import time
|
|||
import requests
|
||||
import six
|
||||
|
||||
from syntribos._i18n import _
|
||||
import syntribos.checks.http as http_checks
|
||||
from syntribos._i18n import _, _LC, _LI # noqa
|
||||
import syntribos.signal
|
||||
from syntribos.utils import string_utils
|
||||
|
||||
|
@ -69,10 +69,8 @@ def log_http_transaction(log, level=logging.DEBUG):
|
|||
log.debug(_safe_decode(logline))
|
||||
except Exception as exception:
|
||||
# Ignore all exceptions that happen in logging, then log them
|
||||
log.info(
|
||||
_LI(
|
||||
'Exception occurred while logging signature of calling'
|
||||
'method in http client'))
|
||||
log.info('Exception occurred while logging signature of '
|
||||
'calling method in http client')
|
||||
log.exception(exception)
|
||||
|
||||
# Make the request and time its execution
|
||||
|
@ -88,8 +86,7 @@ def log_http_transaction(log, level=logging.DEBUG):
|
|||
log.exception(exc)
|
||||
log.log(level, "=" * 80)
|
||||
except Exception as exc:
|
||||
log.critical(_LC(
|
||||
'Call to Requests failed due to exception'))
|
||||
log.critical('Call to Requests failed due to exception')
|
||||
log.exception(exc)
|
||||
signals.register(syntribos.signal.from_generic_exception(exc))
|
||||
raise exc
|
||||
|
@ -109,10 +106,8 @@ def log_http_transaction(log, level=logging.DEBUG):
|
|||
elif 'data' in dir(response.request):
|
||||
request_body = response.request.data
|
||||
else:
|
||||
log.info(
|
||||
_LI(
|
||||
"Unable to log request body, neither a 'data' nor a "
|
||||
"'body' object could be found"))
|
||||
log.info("Unable to log request body, neither a 'data' nor a "
|
||||
"'body' object could be found")
|
||||
|
||||
# requests lib 1.0.4 removed params from response.request
|
||||
request_params = ''
|
||||
|
|
|
@ -27,7 +27,7 @@ import six
|
|||
from six.moves import html_parser
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from syntribos._i18n import _, _LE, _LW # noqa
|
||||
from syntribos._i18n import _
|
||||
|
||||
CONF = cfg.CONF
|
||||
_iterators = {}
|
||||
|
|
|
@ -18,7 +18,7 @@ import sys
|
|||
from oslo_config import cfg
|
||||
|
||||
import syntribos
|
||||
from syntribos._i18n import _, _LE, _LW # noqa
|
||||
from syntribos._i18n import _
|
||||
from syntribos.utils.file_utils import ContentType
|
||||
from syntribos.utils.file_utils import ExistingDirType
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ import unittest
|
|||
from oslo_config import cfg
|
||||
from six.moves import input
|
||||
|
||||
from syntribos._i18n import _
|
||||
import syntribos.config
|
||||
from syntribos.formatters.json_formatter import JSONFormatter
|
||||
from syntribos._i18n import _, _LW, _LE # noqa
|
||||
import syntribos.result
|
||||
import syntribos.tests as tests
|
||||
import syntribos.tests.base
|
||||
|
@ -266,9 +266,8 @@ class Runner(object):
|
|||
LOG = cls.get_logger(file_path)
|
||||
CONF.log_opt_values(LOG, logging.DEBUG)
|
||||
if not file_path.endswith(".template"):
|
||||
LOG.warning(
|
||||
_LW('file.....:%s (SKIPPED - not a .template file)'),
|
||||
file_path)
|
||||
LOG.warning('file.....:%s (SKIPPED - not a .template file)',
|
||||
file_path)
|
||||
continue
|
||||
|
||||
test_names = [t for (t, i) in list_of_tests] # noqa
|
||||
|
@ -319,7 +318,7 @@ class Runner(object):
|
|||
except Exception as e:
|
||||
print("\nError in parsing template:\n \t{0}\n".format(
|
||||
traceback.format_exc()))
|
||||
LOG.error(_LE("Error in parsing template:"))
|
||||
LOG.error("Error in parsing template:")
|
||||
output["failures"].append({
|
||||
"file": file_path,
|
||||
"error": e.__str__()
|
||||
|
@ -385,7 +384,7 @@ class Runner(object):
|
|||
print(_(
|
||||
"Error in parsing template:\n %s\n"
|
||||
) % traceback.format_exc())
|
||||
LOG.error(_LE("Error in parsing template:"))
|
||||
LOG.error("Error in parsing template:")
|
||||
break
|
||||
test_cases = list(
|
||||
test_class.get_test_cases(file_path, req_str))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# limitations under the License.
|
||||
import six
|
||||
|
||||
from syntribos._i18n import _, _LE, _LW # noqa
|
||||
from syntribos._i18n import _
|
||||
|
||||
|
||||
class SignalHolder(object):
|
||||
|
|
|
@ -23,7 +23,7 @@ import requests
|
|||
from six.moves import input
|
||||
|
||||
import syntribos
|
||||
from syntribos._i18n import _, _LE, _LW # noqa
|
||||
from syntribos._i18n import _
|
||||
from syntribos.utils import remotes
|
||||
|
||||
FOLDER = ".syntribos"
|
||||
|
@ -49,7 +49,7 @@ def get_user_home_root():
|
|||
except OSError as e:
|
||||
# Refer https://mail.python.org/pipermail/python-bugs-list/
|
||||
# 2002-July/012691.html
|
||||
LOG.error(_LE("Exception thrown in : %s") % e)
|
||||
LOG.error("Exception thrown in : %s", e)
|
||||
user = pwd.getpwuid(os.getuid())[0]
|
||||
home_path = "~{0}/{1}".format(user, FOLDER)
|
||||
return expand_path(home_path)
|
||||
|
@ -121,8 +121,7 @@ def safe_makedirs(path, force=False):
|
|||
LOG.exception(
|
||||
_("Error overwriting existing folder (%s).") % path)
|
||||
else:
|
||||
LOG.warning(
|
||||
_LW("Folder was already found (%s). Skipping.") % path)
|
||||
LOG.warning("Folder was already found (%s). Skipping.", path)
|
||||
|
||||
|
||||
def create_env_dirs(root_dir, force=False):
|
||||
|
|
|
@ -19,8 +19,8 @@ import tempfile
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
from syntribos._i18n import _
|
||||
from syntribos.clients.http.client import SynHTTPClient
|
||||
from syntribos._i18n import _, _LI, _LE, _LW # noqa
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -61,7 +61,7 @@ def download(uri, cache_dir=None):
|
|||
cache_dir = tempfile.mkdtemp()
|
||||
temp_dirs.append(cache_dir)
|
||||
remote_dirs.append(cache_dir)
|
||||
LOG.debug(_LI("Remote file location: %s") % remote_dirs)
|
||||
LOG.debug("Remote file location: %s", remote_dirs)
|
||||
resp, _ = SynHTTPClient().request("GET", uri)
|
||||
os.chdir(cache_dir)
|
||||
saved_umask = os.umask(0o77)
|
||||
|
@ -71,7 +71,7 @@ def download(uri, cache_dir=None):
|
|||
fh.write(resp.content)
|
||||
return os.path.abspath(fname)
|
||||
except IOError:
|
||||
LOG.error(_LE("IOError in writing the downloaded file to disk."))
|
||||
LOG.error("IOError in writing the downloaded file to disk.")
|
||||
finally:
|
||||
os.umask(saved_umask)
|
||||
|
||||
|
@ -87,8 +87,7 @@ def extract_tar(abs_path):
|
|||
try:
|
||||
os.mkdir("remote")
|
||||
except OSError:
|
||||
LOG.error(_LE(
|
||||
"path exists already, not creating remote directory."))
|
||||
LOG.error("path exists already, not creating remote directory.")
|
||||
remote_path = os.path.abspath("remote")
|
||||
|
||||
def safe_paths(tar_meta):
|
||||
|
@ -108,7 +107,7 @@ def extract_tar(abs_path):
|
|||
with tarfile.open(tar_file, mode="r:gz") as tarf:
|
||||
tarf.extractall(path=remote_path, members=safe_paths(tarf))
|
||||
except tarfile.ExtractError as e:
|
||||
LOG.error(_LE("Unable to extract the file: %s") % e)
|
||||
LOG.error("Unable to extract the file: %s", e)
|
||||
raise
|
||||
os.remove(abs_path)
|
||||
return remote_path
|
||||
|
@ -128,7 +127,7 @@ def get(uri, cache_dir=None):
|
|||
temp = tempfile.TemporaryFile(dir=os.path.abspath(user_base_dir))
|
||||
temp.close()
|
||||
except OSError:
|
||||
LOG.error(_LE("Failed to write remote files to: %s") %
|
||||
LOG.error("Failed to write remote files to: %s",
|
||||
os.path.abspath(user_base_dir))
|
||||
exit(1)
|
||||
abs_path = download(uri, os.path.abspath(user_base_dir))
|
||||
|
|
Loading…
Reference in New Issue