public class Logger extends Object
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
Modifier and Type | Field and Description |
---|---|
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 |
Modifier | Constructor and Description |
---|---|
protected |
Logger() |
Modifier and Type | Method and Description |
---|---|
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 . |
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;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.
Copyright © 2017 FasterXML.com. All rights reserved.