# neutron/tests/unit/hacking/test_checks.py
_all_log_levels = {
+ 'reserved': '_', # this should never be used with a log unless
+ # it is a variable used for a log message and
+ # a exception
'error': '_LE',
'info': '_LI',
'warn': '_LW',
import webob.exc
from neutron.api.v2 import base as v2base
+from neutron.i18n import _LE
LOG = logging.getLogger(__name__)
raise to_class(getattr(e, 'msg', e.message))
# leaked unexpected exception, convert to boring old 500 error and
# hide message from user in case it contained sensitive details
- LOG.exception(_("An unexpected exception was caught: %s") % e)
+ LOG.exception(_LE("An unexpected exception was caught: %s"), e)
raise webob.exc.HTTPInternalServerError(
_("An unexpected internal error occurred."))
self.assertEqual(
0, len(list(checks.validate_log_translations(debug, debug, 'f'))))
for log in logs:
+ bad = 'LOG.%s(_("Bad"))' % log
+ self.assertEqual(
+ 1, len(list(checks.validate_log_translations(bad, bad, 'f'))))
bad = 'LOG.%s("Bad")' % log
self.assertEqual(
1, len(list(checks.validate_log_translations(bad, bad, 'f'))))