From 7d84a88865b7dd04e35a7ea389517596965a0f2b Mon Sep 17 00:00:00 2001
From: Robert Burrell Donkin This is an abstract implementation of the Property getter and setter for log levels. The current log level is checked and then the message will be passed
- * onto the subclass implementation if the level is currently enabled. Set logging level. Get logging level. Log a message with debug log level. If debug log level is enabled,
- * then {@link #debugImpl(Object message)} is called. Log an error with debug log level. If debug log level is enabled,
- * then {@link #debugImpl(Object message, Throwable t)} is called. Log a message with info log level. If info log level is enabled,
- * then {@link #infoImpl(Object message)} is called. Log an error with info log level. If info log level is enabled,
- * then {@link #infoImpl(Object message, Throwable t)} is called. Log a message with warn log level. If warn log level is enabled,
- * then {@link #warnImpl(Object message)} is called. Log an error with warn log level. If warn log level is enabled,
- * then {@link #warnImpl(Object message, Throwable t)} is called. Log a message with error log level. If error log level is enabled,
- * then {@link #errorImpl(Object message)} is called. Log an error with error log level. If error log level is enabled,
- * then {@link #errorImpl(Object message, Throwable t)} is called. Log a message with fatal log level. If fatal log level is enabled,
- * then {@link #fatalImpl(Object message)} is called. Log an error with fatal log level. If fatal log level is enabled,
- * then {@link #fatalImpl(Object message, Throwable t)} is called. Are debug messages currently enabled? This allows expensive operations such as This implementation checks that the log level is debug or lower.
- * If it is, then it passes the request onto {@link #isDebugEnabledImpl}.
- */
- public final boolean isDebugEnabled() {
-
- if (isLevelEnabled(Log.DEBUG)) {
- return isDebugEnabledImpl();
- }
-
- return false;
- }
-
-
- /**
- * Are error messages currently enabled? This allows expensive operations such as This implementation checks that the log level is error or lower.
- * If it is, then it passes the request onto {@link #isErrorEnabledImpl}.
- */
- public final boolean isErrorEnabled() {
-
- if (isLevelEnabled(Log.ERROR)) {
- return isErrorEnabledImpl();
- }
-
- return false;
- }
-
-
- /**
- * Are fatal messages currently enabled? This allows expensive operations such as This implementation checks that the log level is fatal or lower.
- * If it is, then it passes the request onto {@link #isFatalEnabledImpl}.
- */
- public final boolean isFatalEnabled() {
-
- if (isLevelEnabled(Log.FATAL)) {
- return isFatalEnabledImpl();
- }
-
- return false;
- }
-
-
- /**
- * Are info messages currently enabled? This allows expensive operations such as This implementation checks that the log level is info or lower.
- * If it is, then it passes the request onto {@link #isInfoEnabledImpl}.
- */
- public final boolean isInfoEnabled() {
-
- if (isLevelEnabled(Log.INFO)) {
- return isInfoEnabledImpl();
- }
-
- return false;
- }
-
-
- /**
- * Are warn messages currently enabled? This allows expensive operations such as This implementation checks that the log level is warn or lower.
- * If it is, then it passes the request onto {@link #isWarnEnabledImpl}.
- */
- public final boolean isWarnEnabled() {
-
- if (isLevelEnabled(Log.WARN)) {
- return isWarnEnabledImpl();
- }
-
- return false;
- }
-
-
- // ----------------------------------------------- Decorated Implementation
-
- /**
- * [OVERRIDE] Log a message with debug log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log an error with debug log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log a message with info log level .
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log an error with info log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log a message with warn log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log an error with warn log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log a message with error log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log an error with error log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log a message with fatal log level.
- * Subclasses should override this method to implement the logging. [OVERRIDE] Log an error with fatal log level.
- * Subclasses should override this method to implement the logging. Are debug messages currently enabled? Subclasses should override this method if their logger provides
- * a special implementation. Are error messages currently enabled? Subclasses should override this method if their logger provides
- * a special implementation. Are fatal messages currently enabled? Subclasses should override this method if their logger provides
- * a special implementation. Are info messages currently enabled? Subclasses should override this method if their logger provides
- * a special implementation. Are warn messages currently enabled? Subclasses should override this method if their logger provides
- * a special implementation. Log interface.
- * It provides the following common services for the actual concrete
- * implementations:
- *
- * Log Level Property
- * Log Level Enforcement
- * OFF */
- private int currentLogLevel = Log.OFF;
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger.
Log instance by class name */
static public Log getInstance(String name) {
- Log log = (Log)(_logs.get(name));
+ Log log = (Log)(logs.get(name));
if(null == log) {
log = makeNewLogInstance(name);
- _logs.put(name,log);
+ logs.put(name,log);
}
return log;
}
@@ -274,7 +274,7 @@ public class LogSource {
try {
Object[] args = new Object[1];
args[0] = name;
- log = (Log)(_logimplctor.newInstance(args));
+ log = (Log)(logImplctor.newInstance(args));
} catch (Throwable t) {
log = null;
}
@@ -291,7 +291,7 @@ public class LogSource {
* all logs known to me.
*/
static public String[] getLogNames() {
- return (String[])(_logs.keySet().toArray(new String[_logs.size()]));
+ return (String[])(logs.keySet().toArray(new String[logs.size()]));
}
diff --git a/src/java/org/apache/commons/logging/SimpleLog.java b/src/java/org/apache/commons/logging/SimpleLog.java
index b2936b1..09ece4c 100644
--- a/src/java/org/apache/commons/logging/SimpleLog.java
+++ b/src/java/org/apache/commons/logging/SimpleLog.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/SimpleLog.java,v 1.8 2002/01/17 01:47:49 craigmcc Exp $
- * $Revision: 1.8 $
- * $Date: 2002/01/17 01:47:49 $
+ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/Attic/SimpleLog.java,v 1.9 2002/01/17 22:55:43 rdonkin Exp $
+ * $Revision: 1.9 $
+ * $Date: 2002/01/17 22:55:43 $
*
* ====================================================================
*
@@ -85,7 +85,7 @@ import java.util.Date;
* org.apache.commons.logging.simplelog.showlogname -
* Set to true if you want the Log instance name to be
* included in output messages.org.apache.commons.logging.simplelog.showtime -
+ * org.apache.commons.logging.simplelog.showdatetime -
* Set to true if you want the current date and time
* to be included in output messages.Simple start with this */
- static protected final String _prefix =
+ static protected final String systemPrefix =
"org.apache.commons.logging.simplelog.";
- /** All system properties which start with {@link #_prefix} */
- static protected final Properties _simplelogProps = new Properties();
+ /** All system properties which start with {@link #systemPrefix} */
+ static protected final Properties simpleLogProps = new Properties();
/** Include the instance name in the log message? */
- static protected boolean _showlogname = false;
+ static protected boolean showLogName = false;
/** Include the current time in the log message */
- static protected boolean _showtime = false;
+ static protected boolean showDateTime = false;
/** Used to format times */
- static protected DateFormat _df = null;
+ static protected DateFormat dateFormatter = null;
+ // ---------------------------------------------------- Log Level Constants
+
+
+ /** "Debug" level logging. */
+ public static final int LOG_LEVEL_DEBUG = 1;
+ /** "Info" level logging. */
+ public static final int LOG_LEVEL_INFO = 2;
+ /** "Warn" level logging. */
+ public static final int LOG_LEVEL_WARN = 3;
+ /** "Error" level logging. */
+ public static final int LOG_LEVEL_ERROR = 4;
+ /** "Fatal" level logging. */
+ public static final int LOG_LEVEL_FATAL = 5;
// ------------------------------------------------------------ Initializer
@@ -128,8 +141,8 @@ public class SimpleLog extends AbstractLog {
Enumeration enum = System.getProperties().propertyNames();
while(enum.hasMoreElements()) {
String name = (String)(enum.nextElement());
- if(null != name && name.startsWith(_prefix)) {
- _simplelogProps.setProperty(name,System.getProperty(name));
+ if(null != name && name.startsWith(systemPrefix)) {
+ simpleLogProps.setProperty(name,System.getProperty(name));
}
}
@@ -138,7 +151,7 @@ public class SimpleLog extends AbstractLog {
ClassLoader.getSystemResourceAsStream("simplelog.properties");
if(null != in) {
try {
- _simplelogProps.load(in);
+ simpleLogProps.load(in);
in.close();
} catch(java.io.IOException e) {
// ignored
@@ -150,18 +163,18 @@ public class SimpleLog extends AbstractLog {
// ignored
}
- _showlogname = "true".equalsIgnoreCase(
- _simplelogProps.getProperty(
- _prefix + "showlogname","true"));
+ showLogName = "true".equalsIgnoreCase(
+ simpleLogProps.getProperty(
+ systemPrefix + "showlogname","true"));
- _showtime = "true".equalsIgnoreCase(
- _simplelogProps.getProperty(
- _prefix + "showdate","true"));
+ showDateTime = "true".equalsIgnoreCase(
+ simpleLogProps.getProperty(
+ systemPrefix + "showdatetime","true"));
- if(_showtime) {
- _df = new SimpleDateFormat(
- _simplelogProps.getProperty(
- _prefix + "dateformat","yyyy/MM/dd HH:mm:ss:SSS zzz"));
+ if(showDateTime) {
+ dateFormatter = new SimpleDateFormat(
+ simpleLogProps.getProperty(
+ systemPrefix + "dateformat","yyyy/MM/dd HH:mm:ss:SSS zzz"));
}
}
@@ -169,7 +182,9 @@ public class SimpleLog extends AbstractLog {
// ------------------------------------------------------------- Attributes
/** The name of this simple log instance */
- protected String _name = null;
+ protected String logName = null;
+ /** The current log level */
+ protected int currentLogLevel;
// ------------------------------------------------------------ Constructor
@@ -181,39 +196,61 @@ public class SimpleLog extends AbstractLog {
*/
public SimpleLog(String name) {
- _name = name;
+ logName = name;
// set initial log level
// set default log level to ERROR
- setLevel(Log.ERROR);
+ setLevel(SimpleLog.LOG_LEVEL_ERROR);
// set log level from properties
- String lvl = _simplelogProps.getProperty(_prefix + "log." + _name);
+ String lvl = simpleLogProps.getProperty(systemPrefix + "log." + logName);
int i = String.valueOf(name).lastIndexOf(".");
while(null == lvl && i > -1) {
name = name.substring(0,i);
- lvl = _simplelogProps.getProperty(_prefix + "log." + name);
+ lvl = simpleLogProps.getProperty(systemPrefix + "log." + name);
i = String.valueOf(name).lastIndexOf(".");
}
if(null == lvl) {
- lvl = _simplelogProps.getProperty(_prefix + "defaultlog");
+ lvl = simpleLogProps.getProperty(systemPrefix + "defaultlog");
}
if("debug".equalsIgnoreCase(lvl)) {
- setLevel(Log.DEBUG);
+ setLevel(SimpleLog.LOG_LEVEL_DEBUG);
} else if("info".equalsIgnoreCase(lvl)) {
- setLevel(Log.INFO);
+ setLevel(SimpleLog.LOG_LEVEL_INFO);
} else if("warn".equalsIgnoreCase(lvl)) {
- setLevel(Log.WARN);
+ setLevel(SimpleLog.LOG_LEVEL_WARN);
} else if("error".equalsIgnoreCase(lvl)) {
- setLevel(Log.ERROR);
+ setLevel(SimpleLog.LOG_LEVEL_ERROR);
} else if("fatal".equalsIgnoreCase(lvl)) {
- setLevel(Log.FATAL);
+ setLevel(SimpleLog.LOG_LEVEL_FATAL);
}
}
+ // -------------------------------------------------------- Properties
+
+ /**
+ * Set logging level.
+ * + * @param level new logging level + */ + public void setLevel(int currentLogLevel) { + + this.currentLogLevel = currentLogLevel; + } + + + /** + *Get logging level.
+ */ + public int getLevel() { + + return currentLogLevel; + } + + // -------------------------------------------------------- Logging Methods @@ -227,23 +264,23 @@ public class SimpleLog extends AbstractLog { StringBuffer buf = new StringBuffer(); // append date-time if so configured - if(_showtime) { - buf.append(_df.format(new Date())); + if(showDateTime) { + buf.append(dateFormatter.format(new Date())); buf.append(" "); } // append a readable representation of the log leve switch(type) { - case DEBUG: buf.append("[DEBUG] "); break; - case INFO: buf.append("[INFO] "); break; - case WARN: buf.append("[WARN] "); break; - case ERROR: buf.append("[ERROR] "); break; - case FATAL: buf.append("[FATAL] "); break; + case SimpleLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break; + case SimpleLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break; + case SimpleLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break; + case SimpleLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break; + case SimpleLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break; } // append the name of the log instance if so configured - if(_showlogname) { - buf.append(String.valueOf(_name)).append(" - "); + if(showLogName) { + buf.append(String.valueOf(logName)).append(" - "); } // append the message @@ -262,75 +299,193 @@ public class SimpleLog extends AbstractLog { } - // ----------------------------------------------------- Log Implementation - /** - * Prepare then call {@link #log}. + * Is the given log level currently enabled? + * + * @param logLevel is this level enabled? */ - protected final void debugImpl(Object message) { - log(Log.DEBUG,message,null); - } - - /** - * Prepare then call {@link #log}. - */ - protected final void debugImpl(Object message, Throwable t) { - log(Log.DEBUG,message,t); - } - - /** - * Prepare then call {@link #log}. - */ - protected final void infoImpl(Object message) { - log(Log.INFO,message,null); - } - - /** - * Prepare then call {@link #log}. - */ - protected final void infoImpl(Object message, Throwable t) { - log(Log.INFO,message,t); - } - - /** - * Prepare then call {@link #log}. - */ - protected final void warnImpl(Object message) { - log(Log.WARN,message,null); + protected boolean isLevelEnabled(int logLevel) { + // log level are numerically ordered so can use simple numeric + // comparison + return (logLevel >= currentLogLevel); } - /** - * Prepare then call {@link #log}. - */ - protected final void warnImpl(Object message, Throwable t) { - log(Log.WARN,message,t); - } + + // -------------------------------------------------------- Log Implementation + /** - * Prepare then call {@link #log}. + *Log a message with debug log level.
*/ - protected final void errorImpl(Object message) { - log(Log.ERROR,message,null); + public final void debug(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { + log(SimpleLog.LOG_LEVEL_DEBUG, message, null); + } } + /** - * Prepare then call {@link #log}. - */ - protected final void errorImpl(Object message, Throwable t) { - log(Log.ERROR,message,t); + *Log an error with debug log level.
+ */ + public final void debug(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { + log(SimpleLog.LOG_LEVEL_DEBUG, message, t); + } } - /** - * Prepare then call {@link #log}. - */ - protected final void fatalImpl(Object message) { - log(Log.FATAL,message,null); - } /** - * Prepare then call {@link #log}. + *Log a message with info log level.
+ */ + public final void info(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { + log(SimpleLog.LOG_LEVEL_INFO,message,null); + } + } + + + /** + *Log an error with info log level.
*/ - protected final void fatalImpl(Object message, Throwable t) { - log(Log.FATAL,message,t); + public final void info(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { + log(SimpleLog.LOG_LEVEL_INFO, message, t); + } + } + + + /** + *Log a message with warn log level.
+ */ + public final void warn(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { + log(SimpleLog.LOG_LEVEL_WARN, message, null); + } + } + + + /** + *Log an error with warn log level.
+ */ + public final void warn(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { + log(SimpleLog.LOG_LEVEL_WARN, message, t); + } + } + + + /** + *Log a message with error log level.
+ */ + public final void error(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { + log(SimpleLog.LOG_LEVEL_ERROR, message, null); + } + } + + + /** + *Log an error with error log level.
+ */ + public final void error(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { + log(SimpleLog.LOG_LEVEL_ERROR, message, t); + } + } + + + /** + *Log a message with fatal log level.
+ */ + public final void fatal(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { + log(SimpleLog.LOG_LEVEL_FATAL, message, null); + } + } + + + /** + *Log an error with fatal log level.
+ */ + public final void fatal(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { + log(SimpleLog.LOG_LEVEL_FATAL, message, t); + } + } + + + /** + *Are debug messages currently enabled?
+ * + * This allows expensive operations such as String
+ * concatenation to be avoided when the message will be ignored by the
+ * logger.
Are error messages currently enabled?
+ * + * This allows expensive operations such as String
+ * concatenation to be avoided when the message will be ignored by the
+ * logger.
Are fatal messages currently enabled?
+ * + * This allows expensive operations such as String
+ * concatenation to be avoided when the message will be ignored by the
+ * logger.
Are info messages currently enabled?
+ * + * This allows expensive operations such as String
+ * concatenation to be avoided when the message will be ignored by the
+ * logger.
Are warn messages currently enabled?
+ * + * This allows expensive operations such as String
+ * concatenation to be avoided when the message will be ignored by the
+ * logger.
This logger simply uses the last message
- * to set a property.
- * This is used to test the log levels.
- *
- * @author Robert Burrell Donkin
- * @version $Revision: 1.1 $
- */
-public class TestLog extends AbstractLog {
-
- private String message = null;
-
- public String getMessage() {
-
- return message;
- }
-
- public void setMessage(String message) {
-
- this.message = message;
- }
-
- private void setMessage(Object message) {
-
- if (message == null) {
- this.message = null;
- } else {
- this.message = message.toString();
- }
- }
-
- protected void debugImpl(Object message) {
-
- setMessage(message);
- }
-
- protected void debugImpl(Object message, Throwable t) {
-
- debugImpl(message);
- }
-
-
- protected void infoImpl(Object message) {
-
- setMessage(message);
- }
-
- protected void infoImpl(Object message, Throwable t) {
-
- infoImpl(message);
- }
-
- protected void warnImpl(Object message) {
-
- setMessage(message);
- }
-
- protected void warnImpl(Object message, Throwable t) {
-
- warnImpl(message);
- }
-
-
- protected void errorImpl(Object message) {
-
- setMessage(message);
- }
-
- protected void errorImpl(Object message, Throwable t) {
-
- errorImpl(message);
- }
-
- protected void fatalImpl(Object message) {
-
- setMessage(message);
- }
-
- protected void fatalImpl(Object message, Throwable t) {
-
- fatalImpl(message);
- }
-}
-
diff --git a/src/test/org/apache/commons/logging/TestLogLevels.java b/src/test/org/apache/commons/logging/TestLogLevels.java
deleted file mode 100644
index 7b5ef30..0000000
--- a/src/test/org/apache/commons/logging/TestLogLevels.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/test/org/apache/commons/logging/Attic/TestLogLevels.java,v 1.1 2002/01/03 18:49:27 rdonkin Exp $
- * $Revision: 1.1 $
- * $Date: 2002/01/03 18:49:27 $
- *
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Commons", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- *
- * @author Robert Burrell Donkin
- * @version $Revision: 1.1 $
- */
-public class TestLogLevels extends TestCase {
-
- public static Test suite() {
- return new TestSuite(TestLogLevels.class);
- }
-
- public TestLogLevels(String testName) {
- super(testName);
- }
-
- /**
- * Test that AbstractLog correctly passes
- * on calls as per current log level.
- */
- public void testAbstractLogLevelCheck() {
-
- TestLog log = new TestLog();
-
- // test OFF log level
- log.setLevel(Log.OFF);
-
- log.setMessage(null);
- log.debug("DEBUG");
- assertNull(
- "Log level checking failed (DEBUG/OFF)",
- log.getMessage());
-
- log.setMessage(null);
- log.info("INFO");
- assertNull(
- "Log level checking failed (INFO/OFF)",
- log.getMessage());
-
- log.setMessage(null);
- log.error("ERROR");
- assertNull(
- "Log level checking failed (ERROR/OFF)",
- log.getMessage());
-
- log.setMessage(null);
- log.fatal("FATAL");
- assertNull(
- "Log level checking failed (FATAL/OFF)",
- log.getMessage());
-
-
- // test ALL log level
- log.setLevel(Log.ALL);
-
- log.setMessage(null);
- log.debug("DEBUG");
- assertEquals(
- "Log level checking failed (DEBUG/ALL)",
- "DEBUG",
- log.getMessage());
-
- log.setMessage(null);
- log.info("INFO");
- assertEquals(
- "Log level checking failed (INFO/ALL)",
- "INFO",
- log.getMessage());
-
- log.setMessage(null);
- log.error("ERROR");
- assertEquals(
- "Log level checking failed (ERROR/ALL)",
- "ERROR",
- log.getMessage());
-
- log.setMessage(null);
- log.fatal("FATAL");
- assertEquals(
- "Log level checking failed (FATAL/ALL)",
- "FATAL",
- log.getMessage());
-
-
- // test DEBUG log level
- log.setLevel(Log.DEBUG);
-
- log.setMessage(null);
- log.debug("DEBUG");
- assertEquals(
- "Log level checking failed (DEBUG/DEBUG)",
- "DEBUG",
- log.getMessage());
-
- log.setMessage(null);
- log.info("INFO");
- assertEquals(
- "Log level checking failed (INFO/DEBUG)",
- "INFO",
- log.getMessage());
-
- log.setMessage(null);
- log.error("ERROR");
- assertEquals(
- "Log level checking failed (ERROR/DEBUG)",
- "ERROR",
- log.getMessage());
-
- log.setMessage(null);
- log.fatal("FATAL");
- assertEquals(
- "Log level checking failed (FATAL/DEBUG)",
- "FATAL",
- log.getMessage());
-
-
- // test INFO log level
- log.setLevel(Log.INFO);
-
- log.setMessage(null);
- log.debug("DEBUG");
- assertNull(
- "Log level checking failed (DEBUG/INFO)",
- log.getMessage());
-
- log.setMessage(null);
- log.info("INFO");
- assertEquals(
- "Log level checking failed (INFO/INFO)",
- "INFO",
- log.getMessage());
-
- log.setMessage(null);
- log.error("ERROR");
- assertEquals(
- "Log level checking failed (ERROR/INFO)",
- "ERROR",
- log.getMessage());
-
- log.setMessage(null);
- log.fatal("FATAL");
- assertEquals(
- "Log level checking failed (FATAL/INFO)",
- "FATAL",
- log.getMessage());
-
- // test ERROR log level
- log.setLevel(Log.ERROR);
-
- log.setMessage(null);
- log.debug("DEBUG");
- assertNull(
- "Log level checking failed (DEBUG/ERROR)",
- log.getMessage());
-
- log.setMessage(null);
- log.info("INFO");
- assertNull(
- "Log level checking failed (INFO/ERROR)",
- log.getMessage());
-
- log.setMessage(null);
- log.error("ERROR");
- assertEquals(
- "Log level checking failed (ERROR/ERROR)",
- "ERROR",
- log.getMessage());
-
- log.setMessage(null);
- log.fatal("FATAL");
- assertEquals(
- "Log level checking failed (FATAL/ERROR)",
- "FATAL",
- log.getMessage());
-
- // test FATAL log level
- log.setLevel(Log.FATAL);
-
- log.setMessage(null);
- log.debug("DEBUG");
- assertNull(
- "Log level checking failed (DEBUG/FATAL)",
- log.getMessage());
-
- log.setMessage(null);
- log.info("INFO");
- assertNull(
- "Log level checking failed (INFO/FATAL)",
- log.getMessage());
-
- log.setMessage(null);
- log.error("ERROR");
- assertNull(
- "Log level checking failed (ERROR/FATAL)",
- log.getMessage());
-
- log.setMessage(null);
- log.fatal("FATAL");
- assertEquals(
- "Log level checking failed (FATAL/FATAL)",
- "FATAL",
- log.getMessage());
-
- }
-}
-