Fields Summary |
---|
public static final LogLevel | FATAL |
public static final LogLevel | ERROR |
public static final LogLevel | WARN |
public static final LogLevel | INFO |
public static final LogLevel | DEBUG |
public static final LogLevel | SEVERE |
public static final LogLevel | WARNING |
public static final LogLevel | CONFIG |
public static final LogLevel | FINE |
public static final LogLevel | FINER |
public static final LogLevel | FINEST |
protected String | _label |
protected int | _precedence |
private static LogLevel[] | _log4JLevels |
private static LogLevel[] | _jdk14Levels |
private static LogLevel[] | _allDefaultLevels |
private static Map | _logLevelMap |
private static Map | _logLevelColorMap |
private static Map | _registeredLogLevelMap |
Constructors Summary |
---|
public LogLevel(String label, int precedence)
//--------------------------------------------------------------------------
// Constructors:
//--------------------------------------------------------------------------
_log4JLevels = new LogLevel[]{FATAL, ERROR, WARN, INFO, DEBUG};
_jdk14Levels = new LogLevel[]{SEVERE, WARNING, INFO,
CONFIG, FINE, FINER, FINEST};
_allDefaultLevels = new LogLevel[]{FATAL, ERROR, WARN, INFO, DEBUG,
SEVERE, WARNING, CONFIG, FINE, FINER, FINEST};
_logLevelMap = new HashMap();
for (int i = 0; i < _allDefaultLevels.length; i++) {
_logLevelMap.put(_allDefaultLevels[i].getLabel(), _allDefaultLevels[i]);
}
// prepopulate map with levels and text color of black
_logLevelColorMap = new HashMap();
for (int i = 0; i < _allDefaultLevels.length; i++) {
_logLevelColorMap.put(_allDefaultLevels[i], Color.black);
}
_label = label;
_precedence = precedence;
|
Methods Summary |
---|
public boolean | encompasses(org.apache.log4j.lf5.LogLevel level)Returns true if the level supplied is encompassed by this level.
For example, LogLevel.SEVERE encompasses no other LogLevels and
LogLevel.FINE encompasses all other LogLevels. By definition,
a LogLevel encompasses itself.
if (level.getPrecedence() <= getPrecedence()) {
return true;
}
return false;
|
public boolean | equals(java.lang.Object o)
boolean equals = false;
if (o instanceof LogLevel) {
if (this.getPrecedence() ==
((LogLevel) o).getPrecedence()) {
equals = true;
}
}
return equals;
|
public static java.util.List | getAllDefaultLevels()
return Arrays.asList(_allDefaultLevels);
|
public static java.util.List | getJdk14Levels()
return Arrays.asList(_jdk14Levels);
|
public java.lang.String | getLabel()Return the Label of the LogLevel.
return _label;
|
public static java.util.List | getLog4JLevels()
return Arrays.asList(_log4JLevels);
|
public static java.util.Map | getLogLevelColorMap()
return _logLevelColorMap;
|
protected int | getPrecedence()
return _precedence;
|
public int | hashCode()
return _label.hashCode();
|
public static org.apache.log4j.lf5.LogLevel | register(org.apache.log4j.lf5.LogLevel logLevel)Registers a used defined LogLevel.
if (logLevel == null) return null;
// ensure that this is not a default log level
if (_logLevelMap.get(logLevel.getLabel()) == null) {
return (LogLevel) _registeredLogLevelMap.put(logLevel.getLabel(), logLevel);
}
return null;
|
public static void | register(org.apache.log4j.lf5.LogLevel[] logLevels)
if (logLevels != null) {
for (int i = 0; i < logLevels.length; i++) {
register(logLevels[i]);
}
}
|
public static void | register(java.util.List logLevels)
if (logLevels != null) {
Iterator it = logLevels.iterator();
while (it.hasNext()) {
register((LogLevel) it.next());
}
}
|
public static void | resetLogLevelColorMap()
// empty the map
_logLevelColorMap.clear();
// repopulate map and reset text color black
for (int i = 0; i < _allDefaultLevels.length; i++) {
_logLevelColorMap.put(_allDefaultLevels[i], Color.black);
}
|
public void | setLogLevelColorMap(org.apache.log4j.lf5.LogLevel level, java.awt.Color color)
// remove the old entry
_logLevelColorMap.remove(level);
// add the new color entry
if (color == null) {
color = Color.black;
}
_logLevelColorMap.put(level, color);
|
public java.lang.String | toString()
return _label;
|
public static org.apache.log4j.lf5.LogLevel | valueOf(java.lang.String level)Convert a log level label into a LogLevel object.
LogLevel logLevel = null;
if (level != null) {
level = level.trim().toUpperCase();
logLevel = (LogLevel) _logLevelMap.get(level);
}
// Didn't match, Check for registered LogLevels
if (logLevel == null && _registeredLogLevelMap.size() > 0) {
logLevel = (LogLevel) _registeredLogLevelMap.get(level);
}
if (logLevel == null) {
StringBuffer buf = new StringBuffer();
buf.append("Error while trying to parse (" + level + ") into");
buf.append(" a LogLevel.");
throw new LogLevelFormatException(buf.toString());
}
return logLevel;
|