Class SLogger
- java.lang.Object
 - 
- com.identityworksllc.iiq.common.logging.SLogger
 
 
- 
- All Implemented Interfaces:
 org.apache.commons.logging.Log
public class SLogger extends Object implements org.apache.commons.logging.Log
A wrapper around the Commons LoggingLogclass that supplements its features with some extras available in other logging libraries.Since this class itself implements
Log, Beanshell should not care if you simply overwrite the ‘log’ variable in your code.Log strings are interpreted as Java
MessageFormatobjects and have the various features of that class in your JDK version.Values passed as arguments are only evaluated when the appropriate log level is active. If the log level is not active, the operation becomes a quick no-op. This prevents a lot of isDebugEnabled() type checks.
The ‘S’ stands for Super. Super Logger.
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSLogger.FormatterHelper class to format an object for logging.static classSLogger.LevelAn enumeration of log levels to replace the one in log4j 
- 
Constructor Summary
Constructors Constructor Description SLogger(PrintStream Out)Creates a new logger.SLogger(Class<?> Owner)Creates a new logger.SLogger(org.apache.commons.logging.Log WrapLog)Wraps the given log4j logger with this logger 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(Object arg0)voiddebug(Object arg0, Throwable arg1)voiddebug(String MessageTemplate, Object... Args)Logs an debugging message.voiderror(Object arg0)voiderror(Object arg0, Throwable arg1)voiderror(String MessageTemplate, Object... Args)Logs an error message.voidfatal(Object arg0)voidfatal(Object arg0, Throwable arg1)voidfatal(String MessageTemplate, Object... Args)Logs a fatal error message.static SLogger.Formatter[]format(Object[] args)Wraps the arguments for future formatting.voidhandleException(Throwable Error)Handles an exception.voidinfo(Object arg0)voidinfo(Object arg0, Throwable arg1)voidinfo(String MessageTemplate, Object... Args)Logs an informational message.booleanisDebugEnabled()booleanisErrorEnabled()booleanisFatalEnabled()booleanisInfoEnabled()booleanisTraceEnabled()booleanisWarnEnabled()voidlog(SLogger.Level logLevel, String message)Logs the message at the appropriate level according to the Commons Logging APIstatic StringrenderMessage(String messageTemplate, Object[] args)Renders the MessageTemplate using the given argumentsprotected voidsave(SLogger.Level LogLevel, String MessageTemplate, Object[] Args)Hook to allow log messages to be intercepted and saved.protected voidsave(Throwable Error)Hook to allow log messages to be intercepted and saved.voidtrace(Object arg0)voidtrace(Object arg0, Throwable arg1)voidtrace(String MessageTemplate, Object... Args)Logs a trace message.voidwarn(Object arg0)voidwarn(Object arg0, Throwable arg1)voidwarn(String MessageTemplate, Object... Args)Logs a warning message. 
 - 
 
- 
- 
Constructor Detail
- 
SLogger
public SLogger(Class<?> Owner)
Creates a new logger.- Parameters:
 Owner- The class to log messages for.
 
- 
SLogger
public SLogger(org.apache.commons.logging.Log WrapLog)
Wraps the given log4j logger with this logger- Parameters:
 WrapLog- The logger to wrap
 
- 
SLogger
public SLogger(PrintStream Out)
Creates a new logger.- Parameters:
 Out- The output stream to
 
 - 
 
- 
Method Detail
- 
format
public static SLogger.Formatter[] format(Object[] args)
Wraps the arguments for future formatting.The format string is not resolved at this time.
NOTE: In newer versions of logging APIs, this would be accomplished by passing a
Supplierto the API. However, in Commons Logging 1.x, this is not available. It is also not available in Beanshell, as it requires lambda syntax. If that ever becomes available, this class will become obsolete.- Parameters:
 args- The arguments for any place-holders in the message template.- Returns:
 - The formatted arguments.
 
 
- 
renderMessage
public static String renderMessage(String messageTemplate, Object[] args)
Renders the MessageTemplate using the given arguments- Parameters:
 messageTemplate- The message templateargs- The arguments- Returns:
 - The resolved message template
 
 
- 
debug
public void debug(Object arg0)
- Specified by:
 debugin interfaceorg.apache.commons.logging.Log
 
- 
debug
public void debug(Object arg0, Throwable arg1)
- Specified by:
 debugin interfaceorg.apache.commons.logging.Log
 
- 
debug
public void debug(String MessageTemplate, Object... Args)
Logs an debugging message.- Parameters:
 MessageTemplate- A message template, which can either be a plain string or contain place-holders like {0} and {1}.Args- The arguments for any place-holders in the message template.
 
- 
error
public void error(Object arg0)
- Specified by:
 errorin interfaceorg.apache.commons.logging.Log- See Also:
 Log.error(Object)
 
- 
error
public void error(Object arg0, Throwable arg1)
- Specified by:
 errorin interfaceorg.apache.commons.logging.Log- See Also:
 Log.error(Object, Throwable)
 
- 
error
public void error(String MessageTemplate, Object... Args)
Logs an error message.- Parameters:
 MessageTemplate- A message template, which can either be a plain string or contain place-holders like {0} and {1}.Args- The arguments for any place-holders in the message template.
 
- 
fatal
public void fatal(Object arg0)
- Specified by:
 fatalin interfaceorg.apache.commons.logging.Log
 
- 
fatal
public void fatal(Object arg0, Throwable arg1)
- Specified by:
 fatalin interfaceorg.apache.commons.logging.Log
 
- 
fatal
public void fatal(String MessageTemplate, Object... Args)
Logs a fatal error message.- Parameters:
 MessageTemplate- A message template, which can either be a plain string or contain place-holders like {0} and {1}.Args- The arguments for any place-holders in the message template.
 
- 
handleException
public void handleException(Throwable Error)
Handles an exception.- Parameters:
 Error- The exception to handle.
 
- 
info
public void info(Object arg0, Throwable arg1)
- Specified by:
 infoin interfaceorg.apache.commons.logging.Log
 
- 
info
public void info(String MessageTemplate, Object... Args)
Logs an informational message.- Parameters:
 MessageTemplate- A message template, which can either be a plain string or contain place-holders like {0} and {1}.Args- The arguments for any place-holders in the message template.
 
- 
isDebugEnabled
public boolean isDebugEnabled()
- Specified by:
 isDebugEnabledin interfaceorg.apache.commons.logging.Log- See Also:
 Log.isDebugEnabled()
 
- 
isErrorEnabled
public boolean isErrorEnabled()
- Specified by:
 isErrorEnabledin interfaceorg.apache.commons.logging.Log- See Also:
 Log.isErrorEnabled()
 
- 
isFatalEnabled
public boolean isFatalEnabled()
- Specified by:
 isFatalEnabledin interfaceorg.apache.commons.logging.Log- See Also:
 Log.isFatalEnabled()
 
- 
isInfoEnabled
public boolean isInfoEnabled()
- Specified by:
 isInfoEnabledin interfaceorg.apache.commons.logging.Log- See Also:
 Log.isInfoEnabled()
 
- 
isTraceEnabled
public boolean isTraceEnabled()
- Specified by:
 isTraceEnabledin interfaceorg.apache.commons.logging.Log- See Also:
 Log.isTraceEnabled()
 
- 
isWarnEnabled
public boolean isWarnEnabled()
- Specified by:
 isWarnEnabledin interfaceorg.apache.commons.logging.Log- See Also:
 Log.isWarnEnabled()
 
- 
log
public void log(SLogger.Level logLevel, String message)
Logs the message at the appropriate level according to the Commons Logging API- Parameters:
 logLevel- The log level to log atmessage- The message to log
 
- 
save
protected void save(SLogger.Level LogLevel, String MessageTemplate, Object[] Args)
Hook to allow log messages to be intercepted and saved.- Parameters:
 LogLevel- The level to log the message at.MessageTemplate- A message template, which can either be a plain string or contain place-holders like {0} and {1}.Args- The arguments for any place-holders in the message template.
 
- 
save
protected void save(Throwable Error)
Hook to allow log messages to be intercepted and saved.In this version of this class, this is a no-op.
- Parameters:
 Error- The exception to handle.
 
- 
trace
public void trace(Object arg0)
- Specified by:
 tracein interfaceorg.apache.commons.logging.Log
 
- 
trace
public void trace(Object arg0, Throwable arg1)
- Specified by:
 tracein interfaceorg.apache.commons.logging.Log
 
- 
trace
public void trace(String MessageTemplate, Object... Args)
Logs a trace message.- Parameters:
 MessageTemplate- A message template, which can either be a plain string or contain place-holders like {0} and {1}.Args- The arguments for any place-holders in the message template.
 
- 
warn
public void warn(Object arg0)
- Specified by:
 warnin interfaceorg.apache.commons.logging.Log- See Also:
 Log.warn(Object)
 
- 
warn
public void warn(Object arg0, Throwable arg1)
- Specified by:
 warnin interfaceorg.apache.commons.logging.Log- See Also:
 Log.warn(Object, Throwable)
 
 - 
 
 -