Replace LOG.warn

The warn method is deprecated in favor of the warning method.

Change-Id: If7b6bcc4fa6c991f784884feeacb2b20dd2109e6
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami committed 2025-08-19 13:22:22 +00:00
1 parent bf116bae67
commit 018bcb0900
5 files changed
+23 -3

No files matched your search

+1
View File
@@ -3,3 +3,4 @@ Trove Library Specific Commandments
- [T103] Exception messages should be translated
- [T105] Validate no LOG translations
- [T106] LOG.warn() is not allowed. Use LOG.warning()
+1
View File
@@ -77,6 +77,7 @@ import_exceptions = trove.common.i18n
extension =
# T103= checks:check_raised_localized_exceptions
T105 = checks:no_translate_logs
T106 = checks:no_log_warn
paths = ./trove/hacking
[testenv:api-ref]
+3 -3
View File
@@ -76,9 +76,9 @@ def main():
try:
guestagent_utils.disable_user_defined_port()
except Exception as e:
LOG.warn("failed to down the user defined port when "
"network_isolation is set to true due to: %s."
"pass...", str(e))
LOG.warning("failed to down the user defined port when "
"network_isolation is set to true due to: %s."
"pass...", str(e))
pass
# Create user and group for running docker container.
+12
View File
@@ -75,3 +75,15 @@ def no_translate_logs(logical_line, filename, noqa):
msg = "T105: Log message shouldn't be translated."
if _translated_log.match(logical_line):
yield (0, msg)
@core.flake8ext
def no_log_warn(logical_line):
"""Disallow 'LOG.warn('
https://bugs.launchpad.net/tempest/+bug/1508442
T106
"""
if logical_line.startswith('LOG.warn('):
yield (0, 'T106 Use LOG.warning() rather than LOG.warn()')
@@ -70,3 +70,9 @@ class HackingTestCase(trove_testtools.TestCase):
f = tc.check_raised_localized_exceptions
self.assertLinePasses(f, "raise KeyError('Error text')",
'neutron_lib/tests/unit/mytest.py')
def test_no_log_warn(self):
self.assertEqual(1, len(list(tc.no_log_warn(
"LOG.warn(\"LOG.warn is deprecated\")"))))
self.assertEqual(0, len(list(tc.no_log_warn(
"LOG.warning(\"LOG.warn is deprecated\")"))))