public class LogUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
LogUtil.DialogManager
DialogManager is an interface that allows an applcation to add its own buttons
to the error dialogs
|
static class |
LogUtil.LogCategory
Class LogCategory serves as a wrapper around some (undefined for now)
logging facility.
|
Modifier and Type | Field and Description |
---|---|
static int |
printlncnt
Helps to track down println calls
|
Modifier and Type | Method and Description |
---|---|
static void |
addMessageLogger(javax.swing.JLabel t)
Add the given component into the list of components that show messages
from the message method calls
|
static void |
addMessageLogger(javax.swing.JTextArea t)
Add the given component into the list of components that show messages
from the message method calls
|
static boolean |
anyErrors()
If we are in test mode have there been any errors logged.
|
static void |
clearMessage(java.lang.String message)
If the given message is the same as the last shown message
then clear all messages
|
static void |
configure()
Configure the logging
|
static void |
consoleMessage(java.lang.String msg)
Append the given msg to the console text area.
|
static java.awt.Window |
getCurrentWindow()
Finds the most recent active window.
|
static boolean |
getDebugMode()
Set the debug mode
|
static java.util.List |
getExceptions()
Get the list of exceptions that were thrown when in test mode
|
static java.lang.Throwable |
getInnerException(java.lang.Throwable exc)
Get any exception that the given exception wraps (if it does).
|
static boolean |
getInteractiveMode()
_more_
|
static LogUtil.LogCategory |
getLogInstance(java.lang.String name)
Helper that creates a log category.
|
static java.util.List |
getMessages()
Get the list of messages for errors when in test mode
|
static javax.swing.JPanel |
getMultiExceptionsPanel(java.util.List errorMessages,
java.util.List exceptions)
Create the panel that shows multiple exceptions
|
static java.lang.String |
getOutputBuffer(boolean andClearIt)
Get the text that has been written to stderr/stdout when in buffering mode
|
static boolean |
getShowErrorsInGui()
Do we show errors in gui
|
static java.lang.StringBuffer |
getStackDump(boolean asHtml)
return the stack trace of all threads
|
static java.lang.StringBuffer |
getStackDump(boolean asHtml,
boolean onlyRunning)
return the stack trace of all threads
|
static java.lang.String |
getStackTrace()
Return the stack trace of this calling thread
|
static java.lang.String |
getStackTrace(java.lang.Throwable exc)
Get the stack trace from the given exception
|
static boolean |
getTestMode()
Are we in test mode
|
static void |
logException(java.lang.String msg,
java.lang.Throwable exc)
Log the given error message and exception
|
static void |
message(java.lang.String msg)
Show the given string in all of the message components
|
static void |
printException(LogUtil.LogCategory log_,
java.lang.String xmsg,
java.lang.Throwable exc)
Show the given error message/exception in the gui (if not in test mode),
print it to the console and log it to the given Category
|
static void |
printException(LogUtil.LogCategory log_,
java.lang.String xmsg,
java.lang.Throwable exc,
byte[] fileBytes)
Print the exception
|
static void |
printException(LogUtil.LogCategory log_,
java.lang.String xmsg,
java.lang.Throwable originalException,
java.io.File file)
Print the exception
|
static void |
printExceptionNoGui(LogUtil.LogCategory log_,
java.lang.String xmsg,
java.lang.Throwable exc)
Log the given error message/exception to the given LogCategory
|
static void |
printExceptions(java.util.List exceptions)
Print out the list of exceptions
|
static void |
printExceptions(java.util.List errorMessages,
java.util.List exceptions)
Print out the list of error messages and exceptions.
|
static void |
printExceptions(java.lang.String label,
java.util.List errorMessages,
java.util.List exceptions)
Print exceptions
|
static void |
printExceptionsNoGui(java.util.List errorMessages,
java.util.List exceptions)
print out the list of error messages and exceptions.
|
static void |
printExceptionsNoGui(java.lang.String errorMessage,
java.util.List exceptions)
Print out the error messages and exceptions.
|
static void |
println(java.lang.String msg)
This allows you to print to stderr even when we are buffering
|
static void |
printMessage(java.lang.String msg)
Simply print the given message using the default logging LogCategory.
|
static void |
registerWindow(java.awt.Window w)
This registers a window listener on the given window to add and remove the
the window to the list of active windows.
|
static void |
removeMessageLogger(java.lang.Object t)
Remove the given component from the list of message components
|
static void |
setDebugMode(boolean v)
Set the debug mode
|
static void |
setDialogManager(LogUtil.DialogManager manager)
Allows applications to add their own LogUtil.DialogManager
|
static void |
setShowErrorsInGui(boolean v)
set if we show the errors in the gui
|
static void |
setTestMode(boolean v)
Set the test mode.
|
static void |
showConsole()
Create (if needed) the Console window and show it
|
static boolean |
showGui() |
static void |
startOutputBuffer()
Start buffering stderr and stdout
|
static void |
stopOutputBuffer()
Stop buffering stderr and stdout
|
static void |
tracePrintlns()
Helps to track down println calls
|
static void |
userErrorMessage(javax.swing.JLabel label)
Show the given label in an error dialog.
|
static void |
userErrorMessage(LogUtil.LogCategory log_,
java.lang.String msg)
Show the error dialog to the user
|
static void |
userErrorMessage(java.lang.Object msg)
Show the error dialog to the user
|
static void |
userErrorMessage(java.lang.String msg)
Show the error dialog to the user
|
static void |
userMessage(LogUtil.LogCategory log_,
java.lang.String msg)
Show an informational message to the user.
|
static void |
userMessage(LogUtil.LogCategory log_,
java.lang.String msg,
boolean andLog)
Show an informational message to the user.
|
static void |
userMessage(LogUtil.LogCategory log_,
java.lang.String msg,
java.lang.String consoleMsg)
Show an informational message to the user.
|
static void |
userMessage(java.lang.String msg)
Show an informational message to the user.
|
public static LogUtil.LogCategory getLogInstance(java.lang.String name)
name
- The name of the log instancepublic static boolean anyErrors()
public static java.util.List getExceptions()
public static java.util.List getMessages()
public static void setTestMode(boolean v)
v
- The test mode flagpublic static boolean getTestMode()
public static boolean showGui()
public static void setShowErrorsInGui(boolean v)
v
- The test mode flagpublic static boolean getShowErrorsInGui()
public static boolean getInteractiveMode()
public static void setDebugMode(boolean v)
v
- the debug flag (true to print out debug messages)public static boolean getDebugMode()
public static void configure()
public static void logException(java.lang.String msg, java.lang.Throwable exc)
msg
- The error messageexc
- The exceptionpublic static void printExceptionsNoGui(java.util.List errorMessages, java.util.List exceptions)
errorMessages
- exceptions
- public static void printExceptionsNoGui(java.lang.String errorMessage, java.util.List exceptions)
errorMessage
- The messageexceptions
- The exceptionspublic static void printExceptions(java.util.List exceptions)
exceptions
- The exceptionspublic static void println(java.lang.String msg)
msg
- The text to printpublic static void startOutputBuffer()
public static java.lang.String getOutputBuffer(boolean andClearIt)
andClearIt
- Clear the bufferpublic static void stopOutputBuffer()
public static void printExceptions(java.util.List errorMessages, java.util.List exceptions)
errorMessages
- The error messagesexceptions
- The exceptionspublic static void printExceptions(java.lang.String label, java.util.List errorMessages, java.util.List exceptions)
label
- label for the dialogerrorMessages
- list of error messagesexceptions
- List of exceptionspublic static java.lang.Throwable getInnerException(java.lang.Throwable exc)
exc
- The possible exception containing exceptionpublic static javax.swing.JPanel getMultiExceptionsPanel(java.util.List errorMessages, java.util.List exceptions)
errorMessages
- The error messagesexceptions
- The exceptionspublic static java.lang.String getStackTrace()
public static java.lang.String getStackTrace(java.lang.Throwable exc)
exc
- The exception to get the trace frompublic static void showConsole()
public static void consoleMessage(java.lang.String msg)
msg
- public static void setDialogManager(LogUtil.DialogManager manager)
manager
- The singleton dialog manager to usepublic static java.awt.Window getCurrentWindow()
public static void registerWindow(java.awt.Window w)
w
- The windowpublic static void printException(LogUtil.LogCategory log_, java.lang.String xmsg, java.lang.Throwable exc)
log_
- The LogCatgory to log the error toxmsg
- The error messageexc
- The exceptionpublic static void printException(LogUtil.LogCategory log_, java.lang.String xmsg, java.lang.Throwable exc, byte[] fileBytes)
log_
- log categoryxmsg
- messageexc
- exceptionfileBytes
- if non-null then write to a tmp file and tell
the user where to find it.public static void printException(LogUtil.LogCategory log_, java.lang.String xmsg, java.lang.Throwable originalException, java.io.File file)
log_
- log categoryxmsg
- messageoriginalException
- exceptionfile
- If non-null then this is the tmp file that was written
Tell the user about it.public static void printExceptionNoGui(LogUtil.LogCategory log_, java.lang.String xmsg, java.lang.Throwable exc)
log_
- The LogCategory to log the error toxmsg
- The error messageexc
- The exceptionpublic static void printMessage(java.lang.String msg)
msg
- public static void userMessage(java.lang.String msg)
msg
- The messagepublic static void userMessage(LogUtil.LogCategory log_, java.lang.String msg)
log_
- The category to log to. May be null.msg
- The messagepublic static void userMessage(LogUtil.LogCategory log_, java.lang.String msg, java.lang.String consoleMsg)
log_
- The category to log to. May be null.msg
- The messageconsoleMsg
- What to show in the error consolepublic static void userMessage(LogUtil.LogCategory log_, java.lang.String msg, boolean andLog)
log_
- The category to log to. May be null.msg
- The messageandLog
- Should we also log it to the log_public static void userErrorMessage(LogUtil.LogCategory log_, java.lang.String msg)
log_
- category to log to (if not null).msg
- The messagepublic static void userErrorMessage(javax.swing.JLabel label)
label
- labelpublic static void userErrorMessage(java.lang.String msg)
msg
- The messagepublic static void userErrorMessage(java.lang.Object msg)
msg
- May be a String or a Componentpublic static void addMessageLogger(javax.swing.JTextArea t)
t
- The text componentpublic static void addMessageLogger(javax.swing.JLabel t)
t
- The text componentpublic static void removeMessageLogger(java.lang.Object t)
t
- The component to removepublic static void clearMessage(java.lang.String message)
message
- The message to clearpublic static void message(java.lang.String msg)
msg
- The message to showpublic static void tracePrintlns()
public static java.lang.StringBuffer getStackDump(boolean asHtml)
asHtml
- If true generate html instead of textpublic static java.lang.StringBuffer getStackDump(boolean asHtml, boolean onlyRunning)
asHtml
- If true generate html instead of textonlyRunning
- Only show the running threads