Class SimpleLog
- java.lang.Object
-
- org.apache.commons.discovery.log.SimpleLog
-
- All Implemented Interfaces:
org.apache.commons.logging.Log
public class SimpleLog extends java.lang.Object implements org.apache.commons.logging.LogSimple implementation of Log that sends all enabled log messages, for all defined loggers, to System.err.
Hacked from commons-logging SimpleLog for use in discovery. This is intended to be enough of a Log implementation to bootstrap Discovery.
One property:
org.apache.commons.discovery.log.level. valid values: all, trace, debug, info, warn, error, fatal, off.- Version:
- $Id: SimpleLog.java 480374 2006-11-29 03:33:25Z niallp $
- Author:
- Richard A. Sitze, Scott Sanders, Rod Waldhoff, Robert Burrell Donkin
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.text.DateFormatdateFormatterUsed to format timesstatic intLOG_LEVEL_ALLEnable all logging levelsstatic intLOG_LEVEL_DEBUG"Debug" level logging.static intLOG_LEVEL_ERROR"Error" level logging.static intLOG_LEVEL_FATAL"Fatal" level logging.static intLOG_LEVEL_INFO"Info" level logging.static intLOG_LEVEL_OFFEnable no logging levelsstatic intLOG_LEVEL_TRACE"Trace" level logging.static intLOG_LEVEL_WARN"Warn" level logging.protected static intlogLevelThe current log levelprotected java.lang.StringlogNameThe name of this simple log instanceprotected static java.lang.StringPROP_LEVELprotected static booleanshowDateTimeInclude the current time in the log messageprotected static booleanshowLogNameInclude the instance name in the log message?protected static booleanshowShortNameInclude the short name ( last component ) of the logger in the log message.
-
Constructor Summary
Constructors Constructor Description SimpleLog(java.lang.String name)Construct a simple log with given name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(java.lang.Object message)Log a message with debug log level.voiddebug(java.lang.Object message, java.lang.Throwable t)Log an error with debug log level.voiderror(java.lang.Object message)Log a message with error log level.voiderror(java.lang.Object message, java.lang.Throwable t)Log an error with error log level.voidfatal(java.lang.Object message)Log a message with fatal log level.voidfatal(java.lang.Object message, java.lang.Throwable t)Log an error with fatal log level.static intgetLevel()Get logging level.voidinfo(java.lang.Object message)Log a message with info log level.voidinfo(java.lang.Object message, java.lang.Throwable t)Log an error with info log level.booleanisDebugEnabled()Are debug messages currently enabled?booleanisErrorEnabled()Are error messages currently enabled?booleanisFatalEnabled()Are fatal messages currently enabled?booleanisInfoEnabled()Are info messages currently enabled?protected static booleanisLevelEnabled(int level)Is the given log level currently enabled?booleanisTraceEnabled()Are trace messages currently enabled?booleanisWarnEnabled()Are warn messages currently enabled?protected voidlog(int type, java.lang.Object message, java.lang.Throwable t)Do the actual logging.static voidsetLevel(int currentLogLevel)Set logging level.voidtrace(java.lang.Object message)Log a message with debug log level.voidtrace(java.lang.Object message, java.lang.Throwable t)Log an error with debug log level.voidwarn(java.lang.Object message)Log a message with warn log level.voidwarn(java.lang.Object message, java.lang.Throwable t)Log an error with warn log level.
-
-
-
Field Detail
-
LOG_LEVEL_TRACE
public static final int LOG_LEVEL_TRACE
"Trace" level logging.- See Also:
- Constant Field Values
-
LOG_LEVEL_DEBUG
public static final int LOG_LEVEL_DEBUG
"Debug" level logging.- See Also:
- Constant Field Values
-
LOG_LEVEL_INFO
public static final int LOG_LEVEL_INFO
"Info" level logging.- See Also:
- Constant Field Values
-
LOG_LEVEL_WARN
public static final int LOG_LEVEL_WARN
"Warn" level logging.- See Also:
- Constant Field Values
-
LOG_LEVEL_ERROR
public static final int LOG_LEVEL_ERROR
"Error" level logging.- See Also:
- Constant Field Values
-
LOG_LEVEL_FATAL
public static final int LOG_LEVEL_FATAL
"Fatal" level logging.- See Also:
- Constant Field Values
-
LOG_LEVEL_ALL
public static final int LOG_LEVEL_ALL
Enable all logging levels- See Also:
- Constant Field Values
-
LOG_LEVEL_OFF
public static final int LOG_LEVEL_OFF
Enable no logging levels- See Also:
- Constant Field Values
-
PROP_LEVEL
protected static final java.lang.String PROP_LEVEL
- See Also:
- Constant Field Values
-
showLogName
protected static boolean showLogName
Include the instance name in the log message?
-
showShortName
protected static boolean showShortName
Include the short name ( last component ) of the logger in the log message. Default to true - otherwise we'll be lost in a flood of messages without knowing who sends them.
-
showDateTime
protected static boolean showDateTime
Include the current time in the log message
-
dateFormatter
protected static java.text.DateFormat dateFormatter
Used to format times
-
logLevel
protected static int logLevel
The current log level
-
logName
protected java.lang.String logName
The name of this simple log instance
-
-
Method Detail
-
setLevel
public static void setLevel(int currentLogLevel)
Set logging level.
- Parameters:
currentLogLevel- new logging level
-
getLevel
public static int getLevel()
Get logging level.
-
isLevelEnabled
protected static boolean isLevelEnabled(int level)
Is the given log level currently enabled?- Parameters:
level- is this level enabled?
-
log
protected void log(int type, java.lang.Object message, java.lang.Throwable t)Do the actual logging. This method assembles the message and then prints to
System.err.
-
debug
public final void debug(java.lang.Object message)
Log a message with debug log level.
- Specified by:
debugin interfaceorg.apache.commons.logging.Log
-
debug
public final void debug(java.lang.Object message, java.lang.Throwable t)Log an error with debug log level.
- Specified by:
debugin interfaceorg.apache.commons.logging.Log
-
trace
public final void trace(java.lang.Object message)
Log a message with debug log level.
- Specified by:
tracein interfaceorg.apache.commons.logging.Log
-
trace
public final void trace(java.lang.Object message, java.lang.Throwable t)Log an error with debug log level.
- Specified by:
tracein interfaceorg.apache.commons.logging.Log
-
info
public final void info(java.lang.Object message)
Log a message with info log level.
- Specified by:
infoin interfaceorg.apache.commons.logging.Log
-
info
public final void info(java.lang.Object message, java.lang.Throwable t)Log an error with info log level.
- Specified by:
infoin interfaceorg.apache.commons.logging.Log
-
warn
public final void warn(java.lang.Object message)
Log a message with warn log level.
- Specified by:
warnin interfaceorg.apache.commons.logging.Log
-
warn
public final void warn(java.lang.Object message, java.lang.Throwable t)Log an error with warn log level.
- Specified by:
warnin interfaceorg.apache.commons.logging.Log
-
error
public final void error(java.lang.Object message)
Log a message with error log level.
- Specified by:
errorin interfaceorg.apache.commons.logging.Log
-
error
public final void error(java.lang.Object message, java.lang.Throwable t)Log an error with error log level.
- Specified by:
errorin interfaceorg.apache.commons.logging.Log
-
fatal
public final void fatal(java.lang.Object message)
Log a message with fatal log level.
- Specified by:
fatalin interfaceorg.apache.commons.logging.Log
-
fatal
public final void fatal(java.lang.Object message, java.lang.Throwable t)Log an error with fatal log level.
- Specified by:
fatalin interfaceorg.apache.commons.logging.Log
-
isDebugEnabled
public final boolean isDebugEnabled()
Are debug messages currently enabled?
This allows expensive operations such as
Stringconcatenation to be avoided when the message will be ignored by the logger.- Specified by:
isDebugEnabledin interfaceorg.apache.commons.logging.Log
-
isErrorEnabled
public final boolean isErrorEnabled()
Are error messages currently enabled?
This allows expensive operations such as
Stringconcatenation to be avoided when the message will be ignored by the logger.- Specified by:
isErrorEnabledin interfaceorg.apache.commons.logging.Log
-
isFatalEnabled
public final boolean isFatalEnabled()
Are fatal messages currently enabled?
This allows expensive operations such as
Stringconcatenation to be avoided when the message will be ignored by the logger.- Specified by:
isFatalEnabledin interfaceorg.apache.commons.logging.Log
-
isInfoEnabled
public final boolean isInfoEnabled()
Are info messages currently enabled?
This allows expensive operations such as
Stringconcatenation to be avoided when the message will be ignored by the logger.- Specified by:
isInfoEnabledin interfaceorg.apache.commons.logging.Log
-
isTraceEnabled
public final boolean isTraceEnabled()
Are trace messages currently enabled?
This allows expensive operations such as
Stringconcatenation to be avoided when the message will be ignored by the logger.- Specified by:
isTraceEnabledin interfaceorg.apache.commons.logging.Log
-
isWarnEnabled
public final boolean isWarnEnabled()
Are warn messages currently enabled?
This allows expensive operations such as
Stringconcatenation to be avoided when the message will be ignored by the logger.- Specified by:
isWarnEnabledin interfaceorg.apache.commons.logging.Log
-
-