|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openptk.logging.Logger
public class Logger
Singleton class which will hold objects that are available globally to the OpenPTK Framework.
The objects that are managed include:
The usage of the Logger is intended to be extremely simple to use. At any place withing some Java code, the developer should not be required to set anything up. The only thing they need to do is simply call the log....() message on the Logger. See example below:
import org.openptk.logging.Logger; ... Logger.logInfo("HelloWorld!"); ...
By default, the logger is initialized with an OpenPTK SysoutLogger() which simply emits messages to the standard SYSOUT for that platform. Other optional Loggers available with OpenPTK include:
An example of setting up a new CustomLogger is shown below:
import org.openptk.logging.Logger; import org.openptk.logging.LoggingIF; import ....CustomLogger; // Written by developer (must implement LoggingIF) ... { ... LoggingIF myLogger = new CustomLogger(...); Logger.setLogger(myLogger); Logger.logInfo("HelloWorld! Using the new CustomLogger()"); }
Field Summary | |
---|---|
static java.lang.String |
DEFAULT
|
Method Summary | |
---|---|
java.lang.Object |
clone()
Since this is a singleton class, ensure that it cannot be cloned by overridding the Object.clone() method, instead throwing a CloneNotSupportedException. |
static LoggingIF |
getLogger()
Getter for the Logger instance |
static LoggingIF |
getLogger(java.lang.String logId)
Getter for the logger instance |
static void |
log(LoggingLevel logLevel,
java.lang.String msg)
Log a message to DEFAULT Logger at a given LoggingLevel. |
static void |
log(java.lang.String msg)
Log a message to DEFAULT Logger. |
static void |
log(java.lang.String logId,
LoggingLevel logLevel,
java.lang.String msg)
Log a message to a particular Logger at a given LoggingLevel. |
static void |
log(java.lang.String logId,
java.lang.String msg)
Log a message to a particular Logger. |
static void |
logError(java.lang.String msg)
Log an ERROR message to DEFAULT Logger. |
static void |
logError(java.lang.String logId,
java.lang.String msg)
Log an ERROR message to a particular Logger. |
static void |
logInfo(java.lang.String msg)
Log an INFO message to DEFAULT Logger. |
static void |
logInfo(java.lang.String logId,
java.lang.String msg)
Log an INFO message to a particular Logger. |
static void |
logWarning(java.lang.String msg)
Log an WARNING message to DEFAULT Logger. |
static void |
logWarning(java.lang.String logId,
java.lang.String msg)
Log an WARNING message to a particular Logger. |
static void |
setLogger(LoggingIF log)
Add the logging instance to the Logger using a particular name to refer to it, and subsequently get or log messages to later. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT
Method Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public static LoggingIF getLogger()
public static LoggingIF getLogger(java.lang.String logId)
public static void log(LoggingLevel logLevel, java.lang.String msg)
logLevel
- LoggingLevel to log the message tomsg
- String message to be loggedpublic static void log(java.lang.String msg)
msg
- String message to be loggedpublic static void log(java.lang.String logId, LoggingLevel logLevel, java.lang.String msg)
logId
- Name of the Logger to log message tologLevel
- LoggingLevel to log the message tomsg
- String message to be loggedpublic static void log(java.lang.String logId, java.lang.String msg)
logId
- Name of the Logger to log message tomsg
- String message to be loggedpublic static void logError(java.lang.String msg)
msg
- String message to be loggedpublic static void logError(java.lang.String logId, java.lang.String msg)
logId
- Name of the Logger to log message tomsg
- String message to be loggedpublic static void logInfo(java.lang.String msg)
msg
- String message to be loggedpublic static void logInfo(java.lang.String logId, java.lang.String msg)
logId
- Name of the Logger to log message tomsg
- String message to be loggedpublic static void logWarning(java.lang.String msg)
msg
- String message to be loggedpublic static void logWarning(java.lang.String logId, java.lang.String msg)
logId
- Name of the Logger to log message tomsg
- String message to be loggedpublic static void setLogger(LoggingIF log)
log
- Log instance (i.e. SimpleLogger, AtomicLogger)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |