Uploaded image for project: 'Log Tool'
  1. Log Tool
  2. LOGTOOL-120

Locale is not used in the actual string format for loggers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • 2.0.3.Final, 2.1.0.Alpha2
    • 2.0.1.Final
    • None

    Description

      The String.format() method accepts a Locale parameter. We should be using the Locale of the implementation class. Since the format method is called from a final method, we need a polymorphic way of getting the Locale instance; therefore, a protected method should be added to the generated base class like this:

          protected Locale getLoggingLocale() {
              return Locale.ROOT;
          }
      

      Then each subclass should return a locale object specific to that class. The locale object returned should either be one of the following:

      • Locale.CANADA - for "en_CA"
      • Locale.CANADA_FRENCH - for "fr_CA"
      • Locale.CHINESE - for "zh"
      • Locale.ENGLISH - for "en"
      • Locale.FRANCE - for "fr_FR"
      • Locale.FRENCH - for "fr"
      • Locale.GERMAN - for "de"
      • Locale.GERMANY - for "de_DE"
      • Locale.ITALIAN - for "it"
      • Locale.ITALY - for "it_IT"
      • Locale.JAPAN - for "ja_JP"
      • Locale.JAPANESE - for "ja"
      • Locale.KOREA - for "ko_KR"
      • Locale.KOREAN - for "ko"
      • Locale.SIMPLIFIED_CHINESE - for "zh_CN"
      • Locale.TRADITIONAL_CHINESE - for "zh_TW"
      • Locale.UK - for "en_GB"
      • Locale.US - for "en_US"

      If the locale is not one of the above, then the correct Locale should be created in a private constant field of the class like this:

          private static final Locale LOCALE = new Locale("hu");
          // or...
          private static final Locale LOCALE = new Locale("hu", "HU");
          // or...
          private static final Locale LOCALE = new Locale("hu", "HU", "technl");
          // ...and then...
          @Override
          protected Locale getLoggingLocale() {
              return LOCALE;
          }
      

      Finally, all calls to format() should be rewritten to use the locale from the method like this:

                  final NamingException result = new NamingException(String.format(getLoggingLocale(), objectFromReference$str()));
      

      Attachments

        Issue Links

          Activity

            People

              jperkins-rhn James Perkins
              dlloyd@redhat.com David Lloyd
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: