public final class Logger extends ILogger
Each Class that wishes to log must call the Logger.get method with itself
as the only argument. This will return a new Logger object.
To log something, the Calling class must call the desired level method
info, debug, warn, error, fatal with the message to be logged. If the
calling the err or fatal classes, a Throwable object must be passed as a second
argument. Calling the error method will only print the message and
error stack trace. However, calling the fatal method will print the
stack trace, and kill the robot.
| Modifier and Type | Field and Description |
|---|---|
private static java.util.List<LogOutput> |
DEFAULT_OUTS
The Constant m_defOuts.
|
private static java.util.Map<java.lang.Object,Logger> |
LOGGERS
The Constant m_loggers.
|
private boolean |
m_acceptGlobals
The m_acceptGlobals.
|
private static boolean |
m_debugEnabled
The m_debugEnabled.
|
private java.lang.String |
m_label
The m_label.
|
private java.util.List<LogOutput> |
m_outs
The m_outs.
|
static LogOutput |
TERM_ERR
The Constant TERM_ERR.
|
static LogOutput |
TERM_OUT
The Constant TERM_OUT.
|
| Modifier | Constructor and Description |
|---|---|
private |
Logger(java.lang.String label)
Instantiates a new logger.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearOutputs() |
void |
debug(java.lang.String s)
Log an
String to the logger, with debug status. |
void |
enableDebug(boolean enable)
Enable the output of debug statements.
|
void |
error(java.lang.String s,
java.lang.Object o)
Log an
String to the logger, with error status. |
void |
fatal(java.lang.String s,
java.lang.Object o)
Log an
String to the logger, with fatal status. |
static LogOutput |
fileOutput(java.lang.String s)
File output.
|
static ILogger |
get(java.lang.Class c)
Get an ILogger instance for c.
|
static ILogger |
get(java.lang.Object o)
Get an ILogger instance for o.
|
static Logger |
get(java.lang.Object o,
java.lang.String s)
Get an ILogger instance for c.
|
void |
info(java.lang.String s)
Log an
String to the logger, with info status. |
void |
log(LogLevel lvl,
java.lang.String s)
Log an
String to the logger, with log status. |
static void |
registerDefaultFileOutput(java.lang.String s)
Register default file output.
|
static void |
registerDefaultOutput(LogOutput out)
Adds a
LogOutput to the list of default outputs. |
void |
registerOutput(LogOutput out)
Add an output to the logger for this object.
|
static void |
registerToAll(LogOutput out)
Add an output to all the loggers.
|
private void |
sendErrMsg(LogLevel l,
java.lang.String s)
Log an error message.
|
private void |
sendMsg(LogLevel l,
java.lang.String s)
Log a message.
|
void |
severe(java.lang.String s,
java.lang.Object o)
Log an
String to the logger, with severe status. |
void |
warn(java.lang.String s)
Log an
String to the logger, with warning status. |
debug, debug, debug, debug, debug, debug, debug, debug, enableDebug, error, error, error, error, error, error, error, error, error, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, info, info, info, info, info, info, info, info, log, log, log, log, log, log, log, log, severe, severe, severe, severe, severe, severe, severe, severe, severe, warn, warn, warn, warn, warn, warn, warn, warnprivate static final java.util.Map<java.lang.Object,Logger> LOGGERS
private static final java.util.List<LogOutput> DEFAULT_OUTS
private static boolean m_debugEnabled
private final java.util.List<LogOutput> m_outs
private final java.lang.String m_label
private boolean m_acceptGlobals
public static final LogOutput TERM_OUT
public static final LogOutput TERM_ERR
private Logger(java.lang.String label)
label - the labelpublic static ILogger get(java.lang.Object o)
o - the object to get the logger for.public static ILogger get(java.lang.Class c)
c - the class to get the logger for.public static Logger get(java.lang.Object o, java.lang.String s)
o - the object to get the logger for.s - the string to be prefixed to log messages.public static LogOutput fileOutput(java.lang.String s)
s - the spublic static void registerDefaultOutput(LogOutput out)
LogOutput to the list of default outputs.
Also adds the output to all of the current Loggers.
(If they don't already have it)out - a LogOutput instancepublic static void registerDefaultFileOutput(java.lang.String s)
s - the spublic void registerOutput(LogOutput out)
registerOutput in class ILoggerout - a LogOutput instancepublic void clearOutputs()
public void enableDebug(boolean enable)
enableDebug in class ILoggerenable - enable the output of debug statementspublic static void registerToAll(LogOutput out)
out - a LogOutput instanceprivate void sendMsg(LogLevel l, java.lang.String s)
l - the Logging levels - the String to logprivate void sendErrMsg(LogLevel l, java.lang.String s)
l - the Logging levels - the String to logpublic void log(LogLevel lvl, java.lang.String s)
String to the logger, with log status.public void info(java.lang.String s)
String to the logger, with info status.public void debug(java.lang.String s)
String to the logger, with debug status.public void warn(java.lang.String s)
String to the logger, with warning status.public void error(java.lang.String s,
java.lang.Object o)
String to the logger, with error status.public void severe(java.lang.String s,
java.lang.Object o)
String to the logger, with severe status.
If the exception passed to this method is an Error or
Runtime Exception, the Program will Quit