def validate_log_translations(logical_line, filename):
    """Check if log levels has translations and if it's correct.

    S369
    S370
    S371
    S372
    """

    # NOTE(Kezar): sahara/tests included because we don't require translations
    # in tests. sahara/openstack/common included because it's part imported
    # from oslo and we don't change it forever and ever. sahara/db/templates
    # provide separate cli interface so we don't want to translate it.

    ignore_dirs = ["sahara/db/templates",
                   "sahara/tests",
                   "sahara/openstack/common"]
    for directory in ignore_dirs:
        if directory in filename:
            return

    # Translations are not required in the test directory.
    # This will not catch all instances of violations, just direct
    # misuse of the form LOG.info('Message').
    msg = "S369: LOG.info messages require translations `_LI()`!"
    if log_translation_LI.search(logical_line):
        yield (0, msg)
    msg = ("S370: LOG.exception and LOG.error messages require "
           "translations `_LE()`!")
    if log_translation_LE.search(logical_line):
        yield (0, msg)
    msg = "S371: LOG.warning messages require translations `_LW()`!"
    if log_translation_LW.search(logical_line):
        yield (0, msg)
    msg = "S372: LOG.critical messages require translations `_LC()`!"
    if log_translation_LC.search(logical_line):
        yield (0, msg)
dataset/ETHPy150Open openstack/sahara/sahara/utils/hacking/logging_checks.py/validate_log_translations/original