Package org.apache.pivot.util
Class Console
- java.lang.Object
-
- org.apache.pivot.util.Console
-
public final class Console extends java.lang.ObjectUtility class for a simple log to the console, for example from scripts.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConsolegetDefault()static java.lang.StringgetExceptionMessage(java.lang.Throwable t)Get a user-friendly message from the given exception.voidlog(java.lang.String message)Log the given message to the "output" stream.voidlog(java.lang.Throwable t)Log the given exception (basically print the stack trace) to the "error" stream.voidlogError(java.lang.String message)voidlogExceptionMessage(java.lang.Throwable t)voidlogMethod(java.lang.String message, java.lang.Object... args)Log a message along with the calling method's name to the system console.voidlogMethod(java.lang.String prefix, java.lang.String message, java.lang.Object... args)Log a message with an identifying prefix, along with the calling method's name to the system console.voidlogOutput(java.lang.String message)voidsetErrorStream(java.io.PrintStream error)voidsetOutputStream(java.io.PrintStream output)voidsetStreams(java.io.PrintStream stream)
-
-
-
Method Detail
-
getDefault
public static Console getDefault()
-
setStreams
public void setStreams(java.io.PrintStream stream)
-
setOutputStream
public void setOutputStream(java.io.PrintStream output)
-
setErrorStream
public void setErrorStream(java.io.PrintStream error)
-
log
public void log(java.lang.String message)
Log the given message to the "output" stream.- Parameters:
message- The message to log.- See Also:
logOutput(java.lang.String)
-
log
public void log(java.lang.Throwable t)
Log the given exception (basically print the stack trace) to the "error" stream.- Parameters:
t- The exception to log.
-
getExceptionMessage
public static java.lang.String getExceptionMessage(java.lang.Throwable t)
Get a user-friendly message from the given exception.- Parameters:
t- The throwable (exception) in question.- Returns:
- Start with the localized exception message, but use the simple name of the exception if there is no message, or if the exception is one of a short list of "funny" exceptions where the message by itself is ambiguous, prepend the simple name of the exception to the message.
-
logExceptionMessage
public void logExceptionMessage(java.lang.Throwable t)
-
logOutput
public void logOutput(java.lang.String message)
-
logError
public void logError(java.lang.String message)
-
logMethod
public void logMethod(java.lang.String message, java.lang.Object... args)Log a message along with the calling method's name to the system console.- Parameters:
message- The message to be logged toSystem.out, or a format string using the remaining args (can benull).args- The optional arguments used to format the final message.
-
logMethod
public void logMethod(java.lang.String prefix, java.lang.String message, java.lang.Object... args)Log a message with an identifying prefix, along with the calling method's name to the system console.- Parameters:
prefix- Any kind of "marker" prefix to the message (can benull).message- The message to be logged toSystem.out, or a format string using the remaining args (can benull).args- The optional arguments used to format the final message.
-
-