View Javadoc
1   package org.slf4j.event;
2   
3   import static org.slf4j.event.EventConstants.DEBUG_INT;
4   import static org.slf4j.event.EventConstants.ERROR_INT;
5   import static org.slf4j.event.EventConstants.INFO_INT;
6   import static org.slf4j.event.EventConstants.TRACE_INT;
7   import static org.slf4j.event.EventConstants.WARN_INT;
8   
9   /**
10   * SLF4J's internal representation of Level.
11   * 
12   * 
13   * @author Ceki Gülcü
14   * @since 1.7.15
15   */
16  public enum Level {
17  
18      ERROR(ERROR_INT, "ERROR"), WARN(WARN_INT, "WARN"), INFO(INFO_INT, "INFO"), DEBUG(DEBUG_INT, "DEBUG"), TRACE(TRACE_INT, "TRACE");
19  
20      private final int levelInt;
21      private final String levelStr;
22  
23      Level(int i, String s) {
24          levelInt = i;
25          levelStr = s;
26      }
27  
28      public int toInt() {
29          return levelInt;
30      }
31  
32      public static Level intToLevel(int levelInt) {
33          switch (levelInt) {
34          case (TRACE_INT):
35              return TRACE;
36          case (DEBUG_INT):
37              return DEBUG;
38          case (INFO_INT):
39              return INFO;
40          case (WARN_INT):
41              return WARN;
42          case (ERROR_INT):
43              return ERROR;
44          default:
45              throw new IllegalArgumentException("Level integer [" + levelInt + "] not recognized.");
46          }
47      }
48  
49      /**
50       * Returns the string representation of this Level.
51       */
52      public String toString() {
53          return levelStr;
54      }
55  
56  }