public final class LogChannel extends java.lang.Object implements LogSupport, CloseableComponent, LogMessageEvent.Source, LogLevelEvent.Source
LogChannel represents a named channel where you can print out log messages
(errors, infos, warnings, etc). It serves as a message dispatcher who passes the incoming
message to all registered LogPrinter objects.
LogPrinters which are:
LogPrinterConsole which can be activated/deactivated with the
openLogConsolePrinter()/closeLogConsolePrinter() methods. LogPrinterFile which can be activated with the
openLogFilePrinter(File)/closeLogFilePrinter() methods. LogPrinterFrame which can be activated/deactivated with the
openLogFramePrinter(String)/closeLogFramePrinter()methods. closeLogConsolePrinter()
explicitly after construction.LogPrinter,
LogMessageEvent| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_LOG_CHANNEL_NAME |
| Modifier and Type | Method and Description |
|---|---|
void |
addLogLevelListener(LogLevelEvent.Listener l) |
void |
addLogMessageListener(LogMessageEvent.Listener l) |
void |
awaitLogsDelivered() |
void |
close()
Closes all attached LogPrinters.
|
static void |
closeAll() |
void |
closeLogConsolePrinter()
Stops output to the system console.
|
void |
closeLogFilePrinter()
Closes the log-file.
|
void |
closeLogFramePrinter()
Closes the LogFrame window and releases it's resources.
|
static boolean |
existsLogChannel(java.lang.String channelName) |
protected void |
finalize() |
static LogChannel |
getDefault() |
static LogChannel |
getLogChannel(java.lang.String channelName)
Returns a named LogChannel.
|
static java.util.List<LogChannel> |
getLogChannels() |
LogPrinterConsole |
getLogConsolePrinter()
Returns a reference to the LogPrinterConsole or
null if none has been opened
yet with openLogConsole(). |
LogPrinterFile |
getLogFilePrinter()
Returns a reference to the LogPrinterFile or
null if none has been opened yet
with openLogFile(). |
LogPrinterFrame |
getLogFramePrinter()
Returns a reference to the LogPrinterFrame or
null if none has been opened yet
with openLogFrame(String). |
LogLevel |
getLogLevel()
Returns the current LogLevel of this LogChannel.
|
java.lang.String |
getName()
Returns the unique name of this logChannel.
|
boolean |
isClosed() |
boolean |
isLogDebug()
Returns true if a DEBUG log message should be printed.
|
boolean |
isLogVerbose()
Returns true if a VERBOSE log message should be printed.
|
LogMessageEvent |
log(java.lang.Object caller,
LogLevel level,
java.lang.String message,
java.lang.Throwable e)
Creates a message from the given parameters and delivers it to all currently registered
LogPrinter objects.
|
void |
logDebug(java.lang.Object caller,
java.lang.String message) |
void |
logDump(java.lang.Object caller,
java.lang.String message) |
void |
logError(java.lang.Object caller,
java.lang.Exception e) |
void |
logError(java.lang.Object caller,
java.lang.String message) |
void |
logError(java.lang.Object caller,
java.lang.String message,
java.lang.Exception e) |
void |
logFatal(java.lang.Object caller,
java.lang.String message,
java.lang.Exception e) |
void |
logInfo(java.lang.Object caller,
java.lang.String message) |
void |
logVerbose(java.lang.Object caller,
java.lang.String message) |
void |
logWarning(java.lang.Object caller,
java.lang.String message) |
static LogChannel |
newLogChannel(java.lang.String channelName)
Same as
getLogChannel(String) but ensures that the
LogChannel did not yet exist. |
LogPrinterConsole |
openLogConsolePrinter()
Leads the tracing output to the system console (is true by default).
|
LogPrinterFile |
openLogFilePrinter(java.io.File logDir)
Same as openLogFile(File, boolean).
|
LogPrinterFile |
openLogFilePrinter(java.io.File logDir,
boolean toFileOnly)
Same as openLogFile(File, boolean, boolean).
|
LogPrinterFile |
openLogFilePrinter(java.io.File logDir,
boolean useLastLogfile,
boolean toFileOnly)
Requests the LogChannel to open a log file for logging all received messages into.
|
LogPrinterFrame |
openLogFramePrinter(java.lang.String title)
Opens a GUI LogFrame that receives the messages.
|
void |
removeLogLevelListener(LogLevelEvent.Listener l) |
void |
removeLogMessageListener(LogMessageEvent.Listener l) |
void |
setLogLevel(LogLevel level)
Sets the default
LogLevel for LogPrinters
(the default is LogLevel.LOG_INFO. |
java.lang.String |
toString()
Returns the unique name of this logChannel.
|
public static final java.lang.String DEFAULT_LOG_CHANNEL_NAME
public static LogChannel getDefault()
public static java.util.List<LogChannel> getLogChannels()
public static boolean existsLogChannel(java.lang.String channelName)
public static void closeAll()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic static LogChannel getLogChannel(java.lang.String channelName)
public static LogChannel newLogChannel(java.lang.String channelName)
getLogChannel(String) but ensures that the
LogChannel did not yet exist. So you get a new one in any case.public java.lang.String getName()
public java.lang.String toString()
toString in class java.lang.Objectpublic LogPrinterFile openLogFilePrinter(java.io.File logDir) throws java.lang.Exception
java.lang.Exceptionpublic LogPrinterFile openLogFilePrinter(java.io.File logDir, boolean toFileOnly) throws java.lang.Exception
java.lang.Exceptionpublic LogPrinterFile openLogFilePrinter(java.io.File logDir, boolean useLastLogfile, boolean toFileOnly) throws java.lang.Exception
logDir - the target directory for logging (must exist).useLastLogfile - reopens the last logfile and continues writing there.toFileOnly - closes the system console (if any) and logs to the file only.java.lang.Exceptionpublic LogPrinterFile getLogFilePrinter()
null if none has been opened yet
with openLogFile().public void closeLogFilePrinter()
public LogPrinterConsole openLogConsolePrinter()
public LogPrinterConsole getLogConsolePrinter()
null if none has been opened
yet with openLogConsole().public void closeLogConsolePrinter()
public LogPrinterFrame openLogFramePrinter(java.lang.String title)
public LogPrinterFrame getLogFramePrinter()
null if none has been opened yet
with openLogFrame(String).public void closeLogFramePrinter()
public void close()
close in interface java.lang.AutoCloseablepublic boolean isClosed()
public boolean isLogDebug()
LogChannel or any of the
LogPrinters has the LogLevel set to DEBUG or higher (DUMP). isLogDebug in interface LogSupportpublic boolean isLogVerbose()
LogChannel
or any of the LogPrinters has the LogLevel set to VERBOSE or higher (DEBUG, DUMP).
isLogVerbose in interface LogSupportpublic void setLogLevel(LogLevel level)
LogLevel for LogPrinters
(the default is LogLevel.LOG_INFO.
Setting the level to null actually resets to LogLevel.LOG_INFO and
resets all current LogPrinters to use the level of their parent
LogChannel.setLogLevel in interface LogSupportLogPrinterpublic LogLevel getLogLevel()
getLogLevel in interface LogSupportpublic void awaitLogsDelivered()
public void logFatal(java.lang.Object caller,
java.lang.String message,
java.lang.Exception e)
logFatal in interface LogSupportpublic void logError(java.lang.Object caller,
java.lang.String message,
java.lang.Exception e)
logError in interface LogSupportpublic void logError(java.lang.Object caller,
java.lang.Exception e)
public void logError(java.lang.Object caller,
java.lang.String message)
logError in interface LogSupportpublic void logWarning(java.lang.Object caller,
java.lang.String message)
logWarning in interface LogSupportpublic void logInfo(java.lang.Object caller,
java.lang.String message)
logInfo in interface LogSupportpublic void logVerbose(java.lang.Object caller,
java.lang.String message)
logVerbose in interface LogSupportpublic void logDebug(java.lang.Object caller,
java.lang.String message)
logDebug in interface LogSupportpublic void logDump(java.lang.Object caller,
java.lang.String message)
logDump in interface LogSupportpublic LogMessageEvent log(java.lang.Object caller, LogLevel level, java.lang.String message, java.lang.Throwable e)
public void addLogMessageListener(LogMessageEvent.Listener l)
addLogMessageListener in interface LogMessageEvent.Sourcepublic void removeLogMessageListener(LogMessageEvent.Listener l)
removeLogMessageListener in interface LogMessageEvent.Sourcepublic void addLogLevelListener(LogLevelEvent.Listener l)
addLogLevelListener in interface LogLevelEvent.Sourcepublic void removeLogLevelListener(LogLevelEvent.Listener l)
removeLogLevelListener in interface LogLevelEvent.SourceCopyright © 2014 EsprIT-Systems. All Rights Reserved.