The version of Apache log4j used by SoundHelix.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aEp6o
SSH:
git clone USERNAME@vervis.peers.community:aEp6o
Branches
Tags
- 1.3alpha-7
- CHAINSAW_2_SANDBOX_MERGE
- CORE_VERSION
- LEVEL_REPLACES_PRIORITY
- PREALPHA_1_3_AS_OF_2004_05_12
- PRE_CHAINSAW_MODEL_CONVERSION
- PRE_UGLI_MOVE
- TAG_CHAINSAW2_MOVE
- log4j-1.2.17
- log4j-1.2.17-rc1
- v1.3alpha8
- v1.3alpha8-temp
- v1_2_1
- v1_2_10-recalled
- v1_2_11
- v1_2_11_rc1
- v1_2_11rc3
- v1_2_12
- v1_2_12_rc1
- v1_2_12_rc2
- v1_2_12_rc3
- v1_2_12_rc4
- v1_2_12_rc5
- v1_2_12_rc6
- v1_2_13
- v1_2_13_rc1
- v1_2_13_rc2
- v1_2_13_site_update
- v1_2_14
- v1_2_14_maven
- v1_2_14_rc1
- v1_2_14_site_update
- v1_2_15
- v1_2_15_rc1
- v1_2_15_rc2
- v1_2_15_rc3
- v1_2_15_rc4
- v1_2_15_rc5
- v1_2_15_rc6
- v1_2_16
- v1_2_16_rc1
- v1_2_16_rc2
- v1_2_17
- v1_2_17-rc1
- v1_2_17_rc1
- v1_2_17_rc2
- v1_2_17_rc3
- v1_2_2
- v1_2_3
- v1_2_4
- v1_2_6
- v1_2_7
- v1_2_9
- v1_2_alpha0
- v1_2_alpha7
- v1_2beta1
- v1_2final
- v1_3alpha_1
- v1_3alpha_6
- v_1_0
- v_1_0_1
- v_1_0_4
- v_1_1
- v_1_1_1
- v_1_1_2
- v_1_1_3
- v_1_1_b1
- v_1_1b2
- v_1_1b3
- v_1_1b5
- v_1_1b6
- v_1_1b7
- v_1_2beta3
LogLevel.java
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software
* License version 1.1, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*/
package org.apache.log4j.lf5;
import java.awt.*;
import java.util.*;
import java.util.List;
/**
* The LogLevel class defines a set of standard logging levels.
*
* The logging Level objects are ordered and are specified by ordered
* integers. Enabling logging at a given level also enables logging at all
* higher levels.
*
* @author Michael J. Sikorsky
* @author Robert Shaw
* @author Brent Sprecher
* @author Richard Hurst
* @author Brad Marlborough
*/
// Contributed by ThoughtWorks Inc.
public class LogLevel implements java.io.Serializable {
//--------------------------------------------------------------------------
// Constants:
//--------------------------------------------------------------------------
// log4j log levels.
public final static LogLevel FATAL = new LogLevel("FATAL", 0);
public final static LogLevel ERROR = new LogLevel("ERROR", 1);
public final static LogLevel WARN = new LogLevel("WARN", 2);
public final static LogLevel INFO = new LogLevel("INFO", 3);
public final static LogLevel DEBUG = new LogLevel("DEBUG", 4);
// jdk1.4 log levels NOTE: also includes INFO
public final static LogLevel SEVERE = new LogLevel("SEVERE", 1);
public final static LogLevel WARNING = new LogLevel("WARNING", 2);
public final static LogLevel CONFIG = new LogLevel("CONFIG", 4);
public final static LogLevel FINE = new LogLevel("FINE", 5);
public final static LogLevel FINER = new LogLevel("FINER", 6);
public final static LogLevel FINEST = new LogLevel("FINEST", 7);
//--------------------------------------------------------------------------
// Protected Variables:
//--------------------------------------------------------------------------
protected String _label;
protected int _precedence;
//--------------------------------------------------------------------------
// Private Variables:
//--------------------------------------------------------------------------
private static LogLevel[] _log4JLevels;
private static LogLevel[] _jdk14Levels;
private static LogLevel[] _allDefaultLevels;
private static Map _logLevelMap;
private static Map _logLevelColorMap;
private static Map _registeredLogLevelMap = new HashMap();
//--------------------------------------------------------------------------
// Constructors:
//--------------------------------------------------------------------------
static {
_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);
}
}
public LogLevel(String label, int precedence) {
_label = label;
_precedence = precedence;
}
//--------------------------------------------------------------------------
// Public Methods:
//--------------------------------------------------------------------------
/**
* Return the Label of the LogLevel.
*/
public String getLabel() {
return _label;
}
/**
* 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.
*/
public boolean encompasses(LogLevel level) {
if (level.getPrecedence() <= getPrecedence()) {
return true;
}
return false;
}
/**
* Convert a log level label into a LogLevel object.
*
* @param level The label of a level to be converted into a LogLevel.
* @return LogLevel The LogLevel with a label equal to level.
* @throws LogLevelFormatException Is thrown when the level can not be
* converted into a LogLevel.
*/
public static LogLevel valueOf(String level)
throws LogLevelFormatException {
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;
}
/**
* Registers a used defined LogLevel.
*
* @param logLevel The log level to be registered. Cannot be a default LogLevel
* @return LogLevel The replaced log level.
*/
public static LogLevel register(LogLevel 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(LogLevel[] logLevels) {
if (logLevels != null) {
for (int i = 0; i < logLevels.length; i++) {
register(logLevels[i]);
}
}
}
public static void register(List logLevels) {
if (logLevels != null) {
Iterator it = logLevels.iterator();
while (it.hasNext()) {
register((LogLevel) it.next());
}
}
}
public boolean equals(Object o) {
boolean equals = false;
if (o instanceof LogLevel) {
if (this.getPrecedence() ==
((LogLevel) o).getPrecedence()) {
equals = true;
}
}
return equals;
}
public int hashCode() {
return _label.hashCode();
}
public String toString() {
return _label;
}
// set a text color for a specific log level
public void setLogLevelColorMap(LogLevel level, 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 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);
}
}
/**
* @return A <code>List</code> of <code>LogLevel</code> objects that map
* to log4j <code>Priority</code> objects.
*/
public static List getLog4JLevels() {
return Arrays.asList(_log4JLevels);
}
public static List getJdk14Levels() {
return Arrays.asList(_jdk14Levels);
}
public static List getAllDefaultLevels() {
return Arrays.asList(_allDefaultLevels);
}
public static Map getLogLevelColorMap() {
return _logLevelColorMap;
}
//--------------------------------------------------------------------------
// Protected Methods:
//--------------------------------------------------------------------------
protected int getPrecedence() {
return _precedence;
}
//--------------------------------------------------------------------------
// Private Methods:
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Nested Top-Level Classes or Interfaces:
//--------------------------------------------------------------------------
}