Improve Rally Logging (part 1)
- Remove translations Nobody is using translations for Rally and I don't think that anybody is going to use it. Target auditory for Rally are developers/operators which usually know well english. For me this looks like waste of resources, performance degradation (cause we are calling _()), complexity (+1 thing that you need to know) - Pass to log already formatted strings It's very bad because in case of wrong formatting, it doesn't fail instead just writes errors to the logs, as well information about trace is lost, so it's super hard to fix it Log wrapper doesn't allow to use LOG anymore for formatting strings All places are fixed - Improve logging of exceptions LOG.exception() already logs exception, which means it's bad idea to pass str(e) to it. Instead we should provide clear description of what happend. Improved few places to write warnings or exceptions in case of different level of logs. In few places just use LOG.exception - Part of log messages were improved and simplified Change-Id: I800995395e1a8fec61da009906430bc5001e3779
This commit is contained in:
@@ -177,24 +177,6 @@ def check_import_of_logging(logical_line, physical_line, filename):
|
||||
"use `rally.common.logging` instead.")
|
||||
|
||||
|
||||
@skip_ignored_lines
|
||||
def no_translate_debug_logs(logical_line, physical_line, filename):
|
||||
"""Check for "LOG.debug(_("
|
||||
|
||||
As per our translation policy,
|
||||
https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation
|
||||
we shouldn't translate debug level logs.
|
||||
|
||||
* This check assumes that 'LOG' is a logger.
|
||||
* Use filename so we can start enforcing this in specific folders instead
|
||||
of needing to do so all at once.
|
||||
|
||||
N311
|
||||
"""
|
||||
if logical_line.startswith("LOG.debug(_("):
|
||||
yield(0, "N311 Don't translate debug level logs")
|
||||
|
||||
|
||||
@skip_ignored_lines
|
||||
def no_use_conf_debug_check(logical_line, physical_line, filename):
|
||||
"""Check for "cfg.CONF.debug"
|
||||
@@ -606,7 +588,6 @@ def check_opts_import_path(logical_line, physical_line, filename):
|
||||
def factory(register):
|
||||
register(check_assert_methods_from_mock)
|
||||
register(check_import_of_logging)
|
||||
register(no_translate_debug_logs)
|
||||
register(no_use_conf_debug_check)
|
||||
register(assert_true_instance)
|
||||
register(assert_equal_type)
|
||||
|
||||
@@ -112,13 +112,6 @@ class HackingTestCase(test.TestCase):
|
||||
checkres = checks.check_import_of_logging(good, good, "fakefile")
|
||||
self.assertEqual([], list(checkres))
|
||||
|
||||
def test_no_translate_debug_logs(self):
|
||||
|
||||
bad_samples = ["LOG.debug(_('foo'))"]
|
||||
self._assert_bad_samples(checks.no_translate_debug_logs, bad_samples)
|
||||
good_samples = ["LOG.debug('foo')", "LOG.info(_('foo'))"]
|
||||
self._assert_good_samples(checks.no_translate_debug_logs, good_samples)
|
||||
|
||||
def test_no_use_conf_debug_check(self):
|
||||
bad_samples = [
|
||||
"if CONF.debug:",
|
||||
|
||||
Reference in New Issue
Block a user