public final class MessageConsole extends Object
Utilities for message input/output to a console using loggers. The interface provides settings and method to print information, warning, error, trace, and debug messages. While information, warnings, and errors are obviously of different type, trace and debug messages are arbitrary (i.e. whatever you want it to be). This interface only provides means to separate those types, and handle them independently. This also means that, in contrast to logging frameworks, there is no hierarchy of message types. The behavior of each type can be set separately, without impacting the behavior of any other type. Additionally, an über flag is provided to switch off all message printing.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
PRINT_DEBUG_MESSAGES
Print info debug flag.
|
static boolean |
PRINT_ERROR_MESSAGES
Print error message flag.
|
static boolean |
PRINT_INFO_MESSAGES
Print info message flag.
|
static boolean |
PRINT_MESSAGES
Print message flag.
|
static boolean |
PRINT_TRACE_MESSAGES
Print info trace flag.
|
static boolean |
PRINT_WARNING_MESSAGES
Print warning message flag.
|
| Constructor and Description |
|---|
MessageConsole()
Constructor, throws exception since this class should not be instantiated.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
conDebug(String msg)
Prints a debug message to standard out.
|
static void |
conDebug(String msg,
Object... args)
Prints a debug message to to standard out using a
FormattingTuple. |
static void |
conError(String msg)
Prints an error message to standard error.
|
static void |
conError(String msg,
Object... args)
Prints an error message to to standard error using a
FormattingTuple. |
static void |
conInfo(String msg)
Prints an info message to standard out.
|
static void |
conInfo(String msg,
Object... args)
Prints an info message to to standard out using a
FormattingTuple. |
static void |
conTrace(String msg)
Prints a trace message to standard out.
|
static void |
conTrace(String msg,
Object... args)
Prints a trace message to to standard out using a
FormattingTuple. |
static void |
conWarn(String msg)
Prints a warning message to to standard out.
|
static void |
conWarn(String msg,
Object... args)
Prints a warning message to to standard out using a
FormattingTuple. |
static String |
getDefaultEncoding()
Returns the default runtime encoding.
|
static BufferedReader |
getStdIn(String appName)
Returns a new buffered reader for standard in, using UTF-8 encoding.
|
public static boolean PRINT_MESSAGES
Print message flag.
This flag is used as an über flag for printing messages. If set to true, messages in general can be printed using the methods in this interface. If set to false, no messages at all should be printed by any method in this interface.
The flag is static, so it is the same for all applications running in the JVM.
public static boolean PRINT_ERROR_MESSAGES
Print error message flag.
Errors will be printed to standard error by the error methods in this interface.
If this flag is false, no errors will be printed.
If this flag is false and PRINT_MESSAGES is false, no error messages will be printed.
If this flag is true and PRINT_MESSAGES is true, error messages will be printed.
public static boolean PRINT_WARNING_MESSAGES
Print warning message flag.
Warnings will be printed to standard out by the warning methods in this interface.
If this flag is false, no warnings will be printed.
If this flag is false and PRINT_MESSAGES is false, no warning messages will be printed.
If this flag is true and PRINT_MESSAGES is true, warning messages will be printed.
public static boolean PRINT_INFO_MESSAGES
Print info message flag.
Info messages will be printed to standard out by the info methods in this interface.
If this flag is false, no info messages will be printed.
If this flag is false and PRINT_MESSAGES is false, no info messages will be printed.
If this flag is true and PRINT_MESSAGES is true, info messages will be printed.
public static boolean PRINT_TRACE_MESSAGES
Print info trace flag.
Trace messages will be printed to standard out by the info methods in this interface.
If this flag is false, no trace messages will be printed.
If this flag is false and PRINT_MESSAGES is false, no trace messages will be printed.
If this flag is true and PRINT_MESSAGES is true, trace messages will be printed.
public static boolean PRINT_DEBUG_MESSAGES
Print info debug flag.
Debug messages will be printed to standard out by the info methods in this interface.
If this flag is false, no debug messages will be printed.
If this flag is false and PRINT_MESSAGES is false, no debug messages will be printed.
If this flag is true and PRINT_MESSAGES is true, debug messages will be printed.
public MessageConsole()
Constructor, throws exception since this class should not be instantiated.
UnsupportedOperationException - be defaultpublic static void conInfo(String msg)
Prints an info message to standard out.
msg - info message to printpublic static void conInfo(String msg, Object... args)
Prints an info message to to standard out using a FormattingTuple.
msg - info message to printargs - arguments for the messagepublic static void conWarn(String msg)
Prints a warning message to to standard out.
msg - warning message to printpublic static void conWarn(String msg, Object... args)
Prints a warning message to to standard out using a FormattingTuple.
msg - warning message to printargs - arguments for the messagepublic static void conError(String msg)
Prints an error message to standard error.
msg - error message to printpublic static void conError(String msg, Object... args)
Prints an error message to to standard error using a FormattingTuple.
msg - error message to printargs - arguments for the messagepublic static void conTrace(String msg)
Prints a trace message to standard out.
msg - trace message to printpublic static void conTrace(String msg, Object... args)
Prints a trace message to to standard out using a FormattingTuple.
msg - trace message to printargs - arguments for the messagepublic static void conDebug(String msg)
Prints a debug message to standard out.
msg - debug message to printpublic static void conDebug(String msg, Object... args)
Prints a debug message to to standard out using a FormattingTuple.
msg - debug message to printargs - arguments for the messagepublic static String getDefaultEncoding()
Returns the default runtime encoding.
public static BufferedReader getStdIn(String appName)
Returns a new buffered reader for standard in, using UTF-8 encoding.
appName - application name for error messagesCopyright © 2016–2017. All rights reserved.