|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fasterxml.uuid.Logger
public class Logger
This is the simple logging interface used by JUG package. It is meant to provide a minimal but sufficient functionality for JUG to report problems (warnings, errors), in a way that it can be sufficiently customized (redirected, suppressed; even redefined), without forcing overhead of a real full-featured logging sub-system (like log4j or java.util.logging). By being customizable, it is still possible to connect JUG logging into real logging framework (log4j, java.util.logging) used by application or system that uses JUG.
To keep things as light-weight as possible, we won't bother defining separate interface or abstract class -- this class defines both API and the default implementation. It can thus be extended to override functionality to provide things like bridging to "real" logging systems. For simple configuration (suppress all, redirect to another stream) default implementation should be sufficient, however.
Note: package com.fasterxml.uuid.ext
does contain
simple wrappers to connect JUG logging to log4j and java.util.logging:
Log4jLogger
,
JavaUtilLogger
Field Summary | |
---|---|
protected int |
_logLevel
Threshold to use for outputting varius log statements. |
protected PrintStream |
_output1
Output object to use, if defined; initialized to System.err . |
protected PrintWriter |
_output2
Override output used to explicitly specify where to pass diagnostic output, instead of System.err. |
static int |
LOG_ALL
|
static int |
LOG_ERROR_AND_ABOVE
|
static int |
LOG_INFO_AND_ABOVE
|
static int |
LOG_NOTHING
|
static int |
LOG_WARNING_AND_ABOVE
|
Constructor Summary | |
---|---|
protected |
Logger()
|
Method Summary | |
---|---|
protected void |
doLogError(String msg)
|
protected void |
doLogInfo(String msg)
|
protected void |
doLogWarning(String msg)
|
protected void |
doSetLogLevel(int ll)
|
protected void |
doSetOutput(PrintStream str)
|
protected void |
doSetOutput(Writer w)
|
protected void |
doWrite(String msg)
|
protected boolean |
isEnabled()
Internal method used to quickly check if the Logger's output is suppressed or not. |
static void |
logError(String msg)
|
static void |
logInfo(String msg)
|
static void |
logWarning(String msg)
|
static void |
setLogger(Logger inst)
Method that can be used to completely re-define the logging functionality JUG uses. |
static void |
setLogLevel(int level)
Method to set the minimum level of messages that will get logged using currently specific logger instace. |
static void |
setOutput(PrintStream str)
Method that will re-direct output of the logger using the specified PrintStream . |
static void |
setOutput(Writer w)
Method that will re-direct output of the logger using the specified Writer . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int LOG_ALL
public static final int LOG_INFO_AND_ABOVE
public static final int LOG_WARNING_AND_ABOVE
public static final int LOG_ERROR_AND_ABOVE
public static final int LOG_NOTHING
protected int _logLevel
Default is to low only warnings and errors
protected PrintStream _output1
System.err
.
protected PrintWriter _output2
_output1
is null;
Constructor Detail |
---|
protected Logger()
Method Detail |
---|
public static void setLogger(Logger inst)
inst
- Logger instance to use for all logging JUG does; can be
null, but if so, essentially disables all logging.public static void setLogLevel(int level)
LOG_WARNING_AND_ABOVE
is passed as the argument, warnings
and errors will be logged, but informational (INFO) messages will
not.
Note: exact functionality invoked depends on the logger instance: sub-classes of this class may need to do mapping to some other logging sub-system (log4j and JUL logging, for example, use their own severity levels that while generally reasonably easy to map, are nonetheless not one-to-one which the simple logger).
public static void setOutput(PrintStream str)
PrintStream
. Null is allowed, and signifies that all the
output should be suppressed.
Note: exact functionality invoked depends on the logger instance.
public static void setOutput(Writer w)
Writer
. Null is allowed, and signifies that all the
output should be suppressed.
public static void logInfo(String msg)
public static void logWarning(String msg)
public static void logError(String msg)
protected void doSetLogLevel(int ll)
protected void doSetOutput(PrintStream str)
protected void doSetOutput(Writer w)
protected void doLogInfo(String msg)
protected void doLogWarning(String msg)
protected void doLogError(String msg)
protected void doWrite(String msg)
protected boolean isEnabled()
Note: not synchronized since it's read-only method that's return value can not be used for reliable syncing.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |