Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-766

Level.toLocationAwareLoggerInteger() has an unnecessary Level parameter

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • None
    • logback-classic
    • None

    Description

      The Level.toLocationAwareLoggerInteger() method was added in 1.0.1 for http://jira.qos.ch/browse/LOGBACK-219
      This method is not static but it has a Level parameter which is unnecessary. Currently the method signature is the following:
      public int toLocationAwareLoggerInteger(Level level);

      This means that if you have a Level instance in your code and you want to convert it to an int, you can only do it redundantly:
      Level level = ...;
      int levelInt = level.toLocationAwareLoggerInteger(level);

      Instead, it could be a static helper method (similar to fromLocationAwareLoggerInteger()) with the following signature:
      public static int toLocationAwareLoggerInteger(Level level);
      So that you can call:
      Level level = ...;
      int levelInt = Level.toLocationAwareLoggerInteger(level);

      Or, preferably, the Level parameter could be omitted as you already have a level instance:
      public int toLocationAwareLoggerInteger();
      (Then in the method body, "this" could be used instead of the parameter, and the null check becomes unnecessary.)

      So that you can call:
      Level level = ...;
      int levelInt = level.toLocationAwareLoggerInteger();

      Attachments

        Activity

          People

            logback-dev Logback dev list
            patrik.varga Patrik Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: