[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-30-ga2f83e8

Gitbot git-noreply at pixie.qos.ch
Mon Nov 7 22:21:16 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  a2f83e8c0a4779f37c893ac5ad503a3e79f9ae69 (commit)
      from  1cc67039562ac28b9c85e2c9e41269703780f99d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=a2f83e8c0a4779f37c893ac5ad503a3e79f9ae69
http://github.com/ceki/logback/commit/a2f83e8c0a4779f37c893ac5ad503a3e79f9ae69

commit a2f83e8c0a4779f37c893ac5ad503a3e79f9ae69
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Nov 7 22:20:44 2011 +0100

    added a toLocationAwareLoggerInteger method

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/Level.java b/logback-classic/src/main/java/ch/qos/logback/classic/Level.java
index e46393c..acd5750 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/Level.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/Level.java
@@ -93,38 +93,6 @@ public final class Level implements java.io.Serializable {
   }
 
   /**
-   * Convert one of the integer values defined in {@link LocationAwareLogger}
-   * interface to an instance of this class, i.e. a Level.
-   * @param levelInt An integer value representing a level as defined in LocationAwareLogger
-   * @return an instance of this class, i.e. a Level.
-   *
-   * @since 1.0.1
-   */
-  public static Level locationAwareLoggerIntegerToLevel(int levelInt) {
-    Level level;
-    switch (levelInt) {
-    case LocationAwareLogger.TRACE_INT:
-      level = TRACE;
-      break;
-    case LocationAwareLogger.DEBUG_INT:
-      level = DEBUG;
-      break;
-    case LocationAwareLogger.INFO_INT:
-      level = INFO;
-      break;
-    case LocationAwareLogger.WARN_INT:
-      level = WARN;
-      break;
-    case LocationAwareLogger.ERROR_INT:
-      level = ERROR;
-      break;
-    default:
-      throw new IllegalArgumentException(levelInt + " not a valid level value");
-    }
-    return level;
-  }
-
-  /**
    * Returns the string representation of this Level.
    */
   public final String toString() {
@@ -140,28 +108,28 @@ public final class Level implements java.io.Serializable {
 
   /**
    * Convert a Level to an Integer object.
-   * 
+   *
    * @return This level's Integer mapping.
    */
   public final Integer toInteger() {
     switch (levelInt) {
-    case ALL_INT:
-      return ALL_INTEGER;
-    case TRACE_INT:
-      return TRACE_INTEGER;
-    case DEBUG_INT:
-      return DEBUG_INTEGER;
-    case INFO_INT:
-      return INFO_INTEGER;
-    case WARN_INT:
-      return WARN_INTEGER;
-    case ERROR_INT:
-      return ERROR_INTEGER;
-    case OFF_INT:
-      return OFF_INTEGER;
-    default:
-      throw new IllegalStateException("Level " + levelStr + ", " + levelInt
-          + " is unknown.");
+      case ALL_INT:
+        return ALL_INTEGER;
+      case TRACE_INT:
+        return TRACE_INTEGER;
+      case DEBUG_INT:
+        return DEBUG_INTEGER;
+      case INFO_INT:
+        return INFO_INTEGER;
+      case WARN_INT:
+        return WARN_INTEGER;
+      case ERROR_INT:
+        return ERROR_INTEGER;
+      case OFF_INT:
+        return OFF_INTEGER;
+      default:
+        throw new IllegalStateException("Level " + levelStr + ", " + levelInt
+                + " is unknown.");
     }
   }
 
@@ -184,6 +152,7 @@ public final class Level implements java.io.Serializable {
 
   /**
    * This method exists in order to comply with Joran's valueOf convention.
+   *
    * @param sArg
    * @return
    */
@@ -191,7 +160,7 @@ public final class Level implements java.io.Serializable {
     return toLevel(sArg, Level.DEBUG);
   }
 
-  
+
   /**
    * Convert an integer passed as argument to a Level. If the conversion fails,
    * then this method returns {@link #DEBUG}.
@@ -206,22 +175,22 @@ public final class Level implements java.io.Serializable {
    */
   public static Level toLevel(int val, Level defaultLevel) {
     switch (val) {
-    case ALL_INT:
-      return ALL;
-    case TRACE_INT:
-      return TRACE;
-    case DEBUG_INT:
-      return DEBUG;
-    case INFO_INT:
-      return INFO;
-    case WARN_INT:
-      return WARN;
-    case ERROR_INT:
-      return ERROR;
-    case OFF_INT:
-      return OFF;
-    default:
-      return defaultLevel;
+      case ALL_INT:
+        return ALL;
+      case TRACE_INT:
+        return TRACE;
+      case DEBUG_INT:
+        return DEBUG;
+      case INFO_INT:
+        return INFO;
+      case WARN_INT:
+        return WARN;
+      case ERROR_INT:
+        return ERROR;
+      case OFF_INT:
+        return OFF;
+      default:
+        return defaultLevel;
     }
   }
 
@@ -261,10 +230,69 @@ public final class Level implements java.io.Serializable {
   /**
    * Return the flyweight instance of the level received through serizalization,
    * i.e. 'this'.
-   * 
+   *
    * @return The appropriate flyweight instance
    */
   private Object readResolve() {
     return toLevel(this.levelInt);
   }
+
+  /**
+   * Convert one of the integer values defined in {@link LocationAwareLogger}
+   * interface to an instance of this class, i.e. a Level.
+   *
+   * @param levelInt An integer value representing a level as defined in LocationAwareLogger
+   * @return an instance of this class, i.e. a Level.
+   * @since 1.0.1
+   */
+  public static Level fromLocationAwareLoggerInteger(int levelInt) {
+    Level level;
+    switch (levelInt) {
+      case LocationAwareLogger.TRACE_INT:
+        level = TRACE;
+        break;
+      case LocationAwareLogger.DEBUG_INT:
+        level = DEBUG;
+        break;
+      case LocationAwareLogger.INFO_INT:
+        level = INFO;
+        break;
+      case LocationAwareLogger.WARN_INT:
+        level = WARN;
+        break;
+      case LocationAwareLogger.ERROR_INT:
+        level = ERROR;
+        break;
+      default:
+        throw new IllegalArgumentException(levelInt + " not a valid level value");
+    }
+    return level;
+  }
+
+  /**
+   * Convert this level instance to an integer  value defined in the
+   * {@link LocationAwareLogger} interface.
+   *
+   * @param level The level to convert to LocationAwareLogger integer
+   * @return int An integer corresponding to this level as defined in LocationAwareLogger
+   * @since 1.0.1
+   */
+  public int toLocationAwareLoggerInteger(Level level) {
+    if (level == null)
+      throw new IllegalArgumentException("null level parameter is not admitted");
+    switch (level.toInt()) {
+      case Level.TRACE_INT:
+        return LocationAwareLogger.TRACE_INT;
+      case Level.DEBUG_INT:
+        return LocationAwareLogger.DEBUG_INT;
+      case Level.INFO_INT:
+        return LocationAwareLogger.INFO_INT;
+      case Level.WARN_INT:
+        return LocationAwareLogger.WARN_INT;
+      case Level.ERROR_INT:
+        return LocationAwareLogger.ERROR_INT;
+      default:
+        throw new IllegalArgumentException(level + " not a valid level value");
+    }
+  }
 }

-----------------------------------------------------------------------

Summary of changes:
 .../main/java/ch/qos/logback/classic/Level.java    |  164 ++++++++++++--------
 1 files changed, 96 insertions(+), 68 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list