com.partnersoft.core
Interface Log


public interface Log

Standard, class-specific logging facility.

This facility, and the related LogFactory, are designed to insulate Partner code from the specific logging API used. This enables us to change our mind about which to use without rewriting every single class in our codebase. It also enables us to implement simple logging facilities in limited environments such as Java Web Start or J2ME while using the same methodology.

The Apache Jakarta project has a java commons logging subproject with similar goals. At this time (4/11/2006) it doesn't look quite stable and a big new version is in the offing. Also, there is some doubt as to whether it will be truly JVM-neutral since it sounds like it's going to do various tricks involving discovery and reflection, which may not be available on limited JVMs. However, I liked the design of the client end of it, so I have copied their interface for Log and LogFactory. This should make it easier to switch to commons logging if we decide it's the right way to go - just some search-and-replace on class names throughout the codebase.

Classes using logging should use the following boilerplate code:

    import com.partnersoft.core.LogFactory;
    import com.partnersoft.core.Log;
    public class FOO {
        // ******** logging
        private static final Log log = LogFactory.logFor(FOO.class);
 

The skeletal class implementations in skeletons/java all have this boilerplate code included.

Copyright 2006-2007 Partner Software, Inc.

Version:
$Id: Log.java 2474 2010-03-13 14:28:43Z paul $
Author:
Paul Reavis, Russell Cagle

Method Summary
 void debug(java.lang.Object message)
          Log a message with debug log level.
 void debug(java.lang.Object message, java.lang.Throwable t)
          Log an error with debug log level.
 void error(java.lang.Object message)
          Log a message with error log level.
 void error(java.lang.Object message, java.lang.Throwable t)
          Log an error with error log level.
 void fatal(java.lang.Object message)
          Log a message with fatal log level.
 void fatal(java.lang.Object message, java.lang.Throwable t)
          Log an error with fatal log level.
 void info(java.lang.Object message)
          Log a message with info log level.
 void info(java.lang.Object message, java.lang.Throwable t)
          Log an error with info log level.
 boolean isDebugEnabled()
          Is debug logging currently enabled?
 boolean isErrorEnabled()
          Is error logging currently enabled?
 boolean isFatalEnabled()
          Is fatal logging currently enabled?
 boolean isInfoEnabled()
          Is info logging currently enabled?
 boolean isTraceEnabled()
          Is trace logging currently enabled?
 boolean isWarnEnabled()
          Is warn logging currently enabled?
 void popContext()
          Pops the last context name off the context stack.
 void pushContext(java.lang.String contextName)
          Pushes a context name onto the context stack.
 void setDebugEnabled(boolean enabled)
           
 void setErrorEnabled(boolean enabled)
           
 void setFatalEnabled(boolean enabled)
           
 void setInfoEnabled(boolean enabled)
           
 void setTraceEnabled(boolean enabled)
           
 void setWarnEnabled(boolean enabled)
           
 void startDebugTimer(java.lang.String message)
          If isDebugEnabled() is true, starts a stopwatch timing.
 void startInfoTimer(java.lang.String message)
          If isInfoEnabled() is true, starts a stopwatch timing.
 void stopDebugTimer(java.lang.String message)
          If isDebugEnabled() is true, ends the last stopwatch timing and reports the results as a DEBUG message.
 void stopInfoTimer(java.lang.String message)
          If isInfoEnabled() is true, ends the last stopwatch timing and reports the results as a DEBUG message.
 void trace(java.lang.Object message)
          Log a message with trace log level.
 void trace(java.lang.Object message, java.lang.Throwable t)
          Log an error with trace log level.
 void warn(java.lang.Object message)
          Log a message with warn log level.
 void warn(java.lang.Object message, java.lang.Throwable t)
          Log an error with warn log level.
 

Method Detail

isDebugEnabled

boolean isDebugEnabled()
Is debug logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than debug.


setDebugEnabled

void setDebugEnabled(boolean enabled)

isErrorEnabled

boolean isErrorEnabled()
Is error logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than error.


setErrorEnabled

void setErrorEnabled(boolean enabled)

isFatalEnabled

boolean isFatalEnabled()
Is fatal logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than fatal.


setFatalEnabled

void setFatalEnabled(boolean enabled)

isInfoEnabled

boolean isInfoEnabled()
Is info logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than info.


setInfoEnabled

void setInfoEnabled(boolean enabled)

isTraceEnabled

boolean isTraceEnabled()
Is trace logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than trace.


setTraceEnabled

void setTraceEnabled(boolean enabled)

isWarnEnabled

boolean isWarnEnabled()
Is warn logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than warn.


setWarnEnabled

void setWarnEnabled(boolean enabled)

trace

void trace(java.lang.Object message)
Log a message with trace log level.

Parameters:
message - log this message

trace

void trace(java.lang.Object message,
           java.lang.Throwable t)
Log an error with trace log level.

Parameters:
message - log this message
t - log this cause

debug

void debug(java.lang.Object message)
Log a message with debug log level.

Parameters:
message - log this message

debug

void debug(java.lang.Object message,
           java.lang.Throwable t)
Log an error with debug log level.

Parameters:
message - log this message
t - log this cause

info

void info(java.lang.Object message)
Log a message with info log level.

Parameters:
message - log this message

info

void info(java.lang.Object message,
          java.lang.Throwable t)
Log an error with info log level.

Parameters:
message - log this message
t - log this cause

warn

void warn(java.lang.Object message)
Log a message with warn log level.

Parameters:
message - log this message

warn

void warn(java.lang.Object message,
          java.lang.Throwable t)
Log an error with warn log level.

Parameters:
message - log this message
t - log this cause

error

void error(java.lang.Object message)
Log a message with error log level.

Parameters:
message - log this message

error

void error(java.lang.Object message,
           java.lang.Throwable t)
Log an error with error log level.

Parameters:
message - log this message
t - log this cause

fatal

void fatal(java.lang.Object message)
Log a message with fatal log level.

Parameters:
message - log this message

fatal

void fatal(java.lang.Object message,
           java.lang.Throwable t)
Log an error with fatal log level.

Parameters:
message - log this message
t - log this cause

pushContext

void pushContext(java.lang.String contextName)
Pushes a context name onto the context stack. Contexts can be useful e.g. to determine which thread or application a log message is in, or for deeply nested code logic.


popContext

void popContext()
Pops the last context name off the context stack.


startDebugTimer

void startDebugTimer(java.lang.String message)
If isDebugEnabled() is true, starts a stopwatch timing. This may not work properly in multithreaded environments. It logs the given message. Use stopDebugTimer() to end the timing period and report the results.


stopDebugTimer

void stopDebugTimer(java.lang.String message)
If isDebugEnabled() is true, ends the last stopwatch timing and reports the results as a DEBUG message.


startInfoTimer

void startInfoTimer(java.lang.String message)
If isInfoEnabled() is true, starts a stopwatch timing. This may not work properly in multithreaded environments. It logs the given message. Use stopInfoTimer() to end the timing period and report the results.


stopInfoTimer

void stopInfoTimer(java.lang.String message)
If isInfoEnabled() is true, ends the last stopwatch timing and reports the results as a DEBUG message.