|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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.
| 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 |
|---|
boolean isDebugEnabled()
Call this method to prevent having to perform expensive operations (for
example, String concatenation) when the log level is more
than debug.
void setDebugEnabled(boolean enabled)
boolean isErrorEnabled()
Call this method to prevent having to perform expensive operations (for
example, String concatenation) when the log level is more
than error.
void setErrorEnabled(boolean enabled)
boolean isFatalEnabled()
Call this method to prevent having to perform expensive operations (for
example, String concatenation) when the log level is more
than fatal.
void setFatalEnabled(boolean enabled)
boolean isInfoEnabled()
Call this method to prevent having to perform expensive operations (for
example, String concatenation) when the log level is more
than info.
void setInfoEnabled(boolean enabled)
boolean isTraceEnabled()
Call this method to prevent having to perform expensive operations (for
example, String concatenation) when the log level is more
than trace.
void setTraceEnabled(boolean enabled)
boolean isWarnEnabled()
Call this method to prevent having to perform expensive operations (for
example, String concatenation) when the log level is more
than warn.
void setWarnEnabled(boolean enabled)
void trace(java.lang.Object message)
message - log this message
void trace(java.lang.Object message,
java.lang.Throwable t)
message - log this messaget - log this causevoid debug(java.lang.Object message)
message - log this message
void debug(java.lang.Object message,
java.lang.Throwable t)
message - log this messaget - log this causevoid info(java.lang.Object message)
message - log this message
void info(java.lang.Object message,
java.lang.Throwable t)
message - log this messaget - log this causevoid warn(java.lang.Object message)
message - log this message
void warn(java.lang.Object message,
java.lang.Throwable t)
message - log this messaget - log this causevoid error(java.lang.Object message)
message - log this message
void error(java.lang.Object message,
java.lang.Throwable t)
message - log this messaget - log this causevoid fatal(java.lang.Object message)
message - log this message
void fatal(java.lang.Object message,
java.lang.Throwable t)
message - log this messaget - log this causevoid pushContext(java.lang.String contextName)
void popContext()
void startDebugTimer(java.lang.String message)
void stopDebugTimer(java.lang.String message)
void startInfoTimer(java.lang.String message)
void stopInfoTimer(java.lang.String message)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||