public class Logger
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Logger.ErrorInformation
Error information to be dispatched to error listeners.
|
static interface |
Logger.ErrorListener
A listener for error information.
|
static interface |
Logger.Watcher |
Modifier and Type | Field and Description |
---|---|
static int |
LOGGING_TYPE_LOG4J |
static int |
LOGGING_TYPE_SIMPLE |
Constructor and Description |
---|
Logger()
Constructs a default logger.
|
Modifier and Type | Method and Description |
---|---|
static void |
addDebug(java.lang.String debugItem) |
void |
addErrorListener(Logger.ErrorListener errorListener)
Adds an error listener to the logger class.
|
void |
closeLoggingFile() |
void |
debug(java.lang.Class<?> sender,
java.lang.Object object)
Logs a message as a debug information.
|
void |
error(java.lang.Class<?> sender,
java.lang.Object object)
Logs a message as an error.
|
void |
error(java.lang.Class<?> sender,
java.lang.Object object,
java.lang.Throwable throwable)
Logs a message as an error.
|
void |
error(java.lang.Class<?> sender,
java.lang.Throwable throwable)
Logs an exception as an error.
|
void |
error(java.lang.Object object)
Logs a message as an error.
|
void |
error(java.lang.Object object,
java.lang.Throwable throwable)
Logs a message as an error.
|
void |
error(java.lang.Throwable throwable)
Logs an exception as an error.
|
protected void |
finalize() |
static void |
forceDebug()
Forces application to debug in any case, no matter if there are debug file entries or not.
|
static Logger |
getInstance()
Returns the default instance of the Logger.
|
java.lang.String[] |
getLastDebugs() |
static int |
getLoggingType()
Returns the logging type
|
void |
info(java.lang.Class<?> sender,
java.lang.Object object)
Logs a message as information.
|
void |
info(java.lang.Object object)
Logs a message as information.
|
boolean |
isDebugged(java.lang.Class<?> regardedClass)
Returns true if regarded class is in debug mode.
|
boolean |
isOpened()
Returns true of logging file stream has already been opened.
|
static void |
removeDebug(java.lang.String debugItem) |
void |
setAdditionalOutBuffer(java.util.Vector<java.lang.String> additionalOutBuffer)
Sets an additional out buffer for individual presentation issues.
|
void |
setAdditionalOutBuffer(java.util.Vector<java.lang.String> additionalOutBuffer,
int additionalBufferLimit)
Sets an additional out buffer for individual presentation issues.
|
void |
setBypassAdditionalOutBuffer(boolean bypassAdditionalOutBuffer)
Sets the flag to bypass additional out buffers.
|
void |
setBypassErrorListeners(boolean bypassErrorListeners)
Sets the flag to bypass error listeners.
|
static void |
setDebugFilePath(java.lang.String debugFilePath) |
void |
setDurationWatch(boolean durationWatch)
Set on or off watcher for long duration between two debug calls.
|
void |
setDurationWatch(boolean durationWatch,
int maxDuration)
Set on or off watcher for long duration between two debug calls.
|
static void |
setLoggingFilePath(java.io.File loggingFile,
java.lang.String initialInfo)
Causes output to log file as specified (LOGGING_TYPE_SIMPLE).
|
static void |
setLoggingFilePath(java.lang.String loggingFilePath,
boolean append,
java.lang.String initialInfo)
Causes output to log file as specified (LOGGING_TYPE_SIMPLE).
|
static void |
setLoggingFilePath(java.lang.String loggingFilePath,
java.lang.String initialInfo)
Causes output to log file as specified (LOGGING_TYPE_SIMPLE).
|
static void |
setLoggingType(int newLoggingType)
Sets the logging type
|
void |
setWatcher(Logger.Watcher watcher) |
void |
warn(java.lang.Class<?> sender,
java.lang.Object object)
Logs a message as warning.
|
void |
warnIfDebugged(java.lang.Class<?> sender,
java.lang.Object object)
Warns (including stack trace) if debugged or adds message to context buffer if not.
|
void |
writeStacktraceIfDebugged(java.lang.Class<?> regardedClass)
Writes stack trace if regarded this is in debug mode.
|
public static final int LOGGING_TYPE_SIMPLE
public static final int LOGGING_TYPE_LOG4J
public static int getLoggingType()
LOGGING_TYPE_SIMPLE
,
LOGGING_TYPE_LOG4J
public static void setLoggingType(int newLoggingType)
newLoggingType
- the logging typeLOGGING_TYPE_SIMPLE
,
LOGGING_TYPE_LOG4J
public static void setDebugFilePath(java.lang.String debugFilePath)
public static void setLoggingFilePath(java.io.File loggingFile, java.lang.String initialInfo)
loggingFilePath
- the path to the log file to useinitialInfo
- the initial info to write into the log filepublic static void setLoggingFilePath(java.lang.String loggingFilePath, java.lang.String initialInfo)
loggingFilePath
- the path to the log file to useinitialInfo
- the initial info to write into the log filepublic static void setLoggingFilePath(java.lang.String loggingFilePath, boolean append, java.lang.String initialInfo)
loggingFilePath
- the path to the log file to useappend
- if true
, then bytes will be written to the end of the file rather than the beginninginitialInfo
- the initial info to write into the log filepublic static void addDebug(java.lang.String debugItem)
public static void removeDebug(java.lang.String debugItem)
public static void forceDebug()
public static final Logger getInstance()
public boolean isOpened()
public void setDurationWatch(boolean durationWatch)
durationWatch
- whether or not long duration is to be watchedpublic void setDurationWatch(boolean durationWatch, int maxDuration)
durationWatch
- whether or not long duration is to be watchedmaxDurationthe
- duration maximum (milliseconds) to prevent from outputpublic void addErrorListener(Logger.ErrorListener errorListener)
errorListener
- the error listener to addpublic void setWatcher(Logger.Watcher watcher)
public void setAdditionalOutBuffer(java.util.Vector<java.lang.String> additionalOutBuffer)
additionalOutBuffer
- the additional out buffer to be informed.public void setAdditionalOutBuffer(java.util.Vector<java.lang.String> additionalOutBuffer, int additionalBufferLimit)
additionalOutBuffer
- the additional out buffer to be informed.additionalBufferLimit
- the limitation buffer extension in order to avoid OutOfMemoryExceptionspublic void setBypassAdditionalOutBuffer(boolean bypassAdditionalOutBuffer)
bypassAdditionalOutBuffer
- whether or not additional out buffers are to be bypassed.public void setBypassErrorListeners(boolean bypassErrorListeners)
bypassErrorListeners
- whether or not error listeners are to be bypassed.public void info(java.lang.Object object)
object
- the message (text) to logpublic void info(java.lang.Class<?> sender, java.lang.Object object)
sender
- the message sending classobject
- the message (text) to logpublic void warnIfDebugged(java.lang.Class<?> sender, java.lang.Object object)
sender
- the message sending classobject
- the message (text) to logpublic void warn(java.lang.Class<?> sender, java.lang.Object object)
sender
- the message sending classobject
- the message (text) to logpublic void error(java.lang.Object object)
object
- the message (text) to logpublic void error(java.lang.Throwable throwable)
throwable
- the exception to logpublic void error(java.lang.Class<?> sender, java.lang.Throwable throwable)
sender
- the message sending classthrowable
- the exception to logpublic void error(java.lang.Object object, java.lang.Throwable throwable)
object
- the message (text) to logthrowable
- the exception to logpublic void error(java.lang.Class<?> sender, java.lang.Object object)
sender
- the message sending classobject
- the message (text) to logpublic void error(java.lang.Class<?> sender, java.lang.Object object, java.lang.Throwable throwable)
sender
- the message sending classobject
- the message (text) to logthrowable
- the exception to logpublic void debug(java.lang.Class<?> sender, java.lang.Object object)
sender
- the message sending classobject
- the message (text) to logpublic void writeStacktraceIfDebugged(java.lang.Class<?> regardedClass)
Logger.getInstance().writeStacktraceIfDebugged(getClass());
regardedClass
- the regarded classpublic boolean isDebugged(java.lang.Class<?> regardedClass)
regardedClass
- the regarded classpublic java.lang.String[] getLastDebugs()
public void closeLoggingFile()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Copyright 1998-2023 Christoph Mueller, Kaerntner Str. 56, D-70469 Stuttgart, Germany, https://www.perpus.de