|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.logging.Log
public final class Log
A basic application log. Log events by default go to console, but can be redirected via listeners and adapters.
getFilter()
or using the shortcuts such as
enableAll()
.
The initial set of enabled console events can also be controlled
via the system properties dfc.log.console.show
and
dfc.log.console.hide
. For example, to show only
WARNING and ALARM events, you could use
"-Ddfc.log.console.show=WARNING,ALARM" on the command line.
Example usage:
Log.info ("Starting application", this); try { ... } catch (Exception ex) { Log.alarm ("Unexpected exception", this, ex); }
FileLogger
,
LogListener
,
LogMessageBuffer
Field Summary | |
---|---|
static int |
ALARM
|
static int |
DIAGNOSTIC
|
static int |
INFO
|
static int |
INTERNAL_ERROR
|
static int |
PERFORMANCE
|
static int |
SYSTEM_EVENT
|
static int |
TRACE
|
static int |
WARNING
|
Method Summary | |
---|---|
static void |
add(int type,
String messageStr,
Object source)
Add a message to the log. |
static void |
add(int type,
String messageStr,
Object source,
Throwable exception)
Add a message to the log. |
static void |
add(LogEvent event)
Log an existing log event. |
static void |
addLogListener(LogListener l)
|
static void |
alarm(String messageStr,
Object source)
An alarm is for serious errors that indicate the program has failed in some non-recoverable way. |
static void |
alarm(String messageStr,
Object source,
Throwable ex)
An alarm is for serious errors that indicate the program has failed in some non-recoverable way. |
static String |
applicationName()
Get the application name, or null of none set. |
static void |
diagnostic(String messageStr,
Object source)
A diagnostic is something that is likely to be useful for diagnosing problems, and thus is more interesting than a trace, but si not an actual warning of anything going wrong. |
static void |
diagnostic(String messageStr,
Object source,
Throwable ex)
A diagnostic is something that is likely to be useful for diagnosing problems, and thus is more interesting than a trace, but si not an actual warning of anything going wrong. |
static void |
disableAll()
Shortcut for disabling printing all log events from the console. |
static void |
enableAll()
Shortcut for enabling printing all log events to the console. |
static void |
enableAwtErrorLogging()
Enable redirection of unhandled exceptions in the AWT event thread to the log. |
protected static void |
fireMessageReceived(LogEvent e)
|
static String |
getDateString(Date time)
Generate a string from a date formatted in the same way as the logger. |
static PrintWriter |
getErrorOutput()
|
static LogFilter |
getFilter()
Get the filter for sending log events to the console. |
static PrintWriter |
getInfoOutput()
|
static String |
getTypeString(int type)
Get a string for a given log message type (INFO, WARNING, etc). |
static void |
info(String messageStr,
Object source)
An info message is for the information that may be of interest to the user, rather than a trace for the developer. |
static void |
internalError(String messageStr,
Object source)
Indicates some extremely serious error has occurred, usually requiring immediate shutdown of the system. |
static void |
internalError(String messageStr,
Object source,
Throwable ex)
Indicates some extremely serious error has occurred, usually requiring immediate shutdown of the system. |
static boolean |
isEnabled(int type)
|
static void |
printException(PrintWriter str,
Throwable exception)
|
static boolean |
printExceptionMessage(PrintWriter str,
Throwable exception,
int maxLength)
|
static void |
printExceptionTrace(PrintWriter str,
Throwable exception,
int maxLength)
Prints the exception stack trace. |
static boolean |
printMessage(PrintWriter str,
Date time,
DateFormat dateFormat,
int type,
String messageStr)
|
static boolean |
printMessage(PrintWriter logWriter,
Date time,
DateFormat dateFormat,
int type,
String messageStr,
int maxLength)
Prints a message to the supplied PrintWriter instance. |
static boolean |
printMessage(PrintWriter str,
Date time,
int type,
String messageStr)
|
static void |
readLogFilterSystemProperty()
Read the dfc.log.console.show and dfc.log.console.hide system properties and update the filter settings. |
static void |
removeLogListener(LogListener l)
|
static void |
setApplicationName(String newValue)
Set the user-readable application name. |
static void |
setEnabled(int type,
boolean enabled)
Shortcut to set filtering for sending log events to the console. |
static void |
setErrorOutput(PrintWriter newValue)
Set the stream that error messages are echoed to. |
static void |
setInfoOutput(PrintWriter newValue)
Set the stream that info (non-error) messages are echoed to. |
static void |
setOutput(PrintWriter newOutput)
Sets both the info and error output streams that log messages are echoed to. |
static int |
stringToType(String typeName)
Get the type code for a log entry type. |
static String |
toLogString(LogEvent event)
Generate a string from a log event, minus the application and date info. |
static void |
trace(String messageStr,
Object source)
A trace is used to show the current state of the program for debugging purposes. |
static void |
trace(String messageStr,
Object source,
Throwable ex)
A trace is used to show the current state of the program for debugging purposes. |
static String |
typeToString(int type)
|
static void |
warn(String messageStr,
Object source)
A warning is an alert that something anomalous has happened that *may* indicate something has gone wrong. |
static void |
warn(String messageStr,
Object source,
Throwable ex)
A warning is an alert that something anomalous has happened that *may* indicate something has gone wrong. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRACE
public static final int INFO
public static final int WARNING
public static final int ALARM
public static final int PERFORMANCE
public static final int DIAGNOSTIC
public static final int SYSTEM_EVENT
public static final int INTERNAL_ERROR
Method Detail |
---|
public static void readLogFilterSystemProperty()
public static void setApplicationName(String newValue)
public static String applicationName()
setApplicationName(String)
public static void enableAwtErrorLogging()
public static void setOutput(PrintWriter newOutput)
setInfoOutput(PrintWriter)
,
setErrorOutput(PrintWriter)
public static void setInfoOutput(PrintWriter newValue)
setErrorOutput(PrintWriter)
public static PrintWriter getInfoOutput()
public static void setErrorOutput(PrintWriter newValue)
setInfoOutput(PrintWriter)
public static PrintWriter getErrorOutput()
public static LogFilter getFilter()
public static void setEnabled(int type, boolean enabled)
public static boolean isEnabled(int type)
public static void disableAll()
public static void enableAll()
public static String getDateString(Date time)
public static String getTypeString(int type)
typeToString(int)
.
public static int stringToType(String typeName) throws IllegalArgumentException
typeName
- One of "TRACE", "INFO", "WARNING", "ALARM",
"PERFORMANCE", "DIAGNOSTIC", "SYSTEM_EVENT",
"INTERNAL_ERROR"
IllegalArgumentException
- if typeName is not valid.typeToString(int)
public static String typeToString(int type)
public static void add(LogEvent event)
public static void add(int type, String messageStr, Object source)
type
- The type of message: TRACE, INFO, WARNING, ALARM, etc.messageStr
- The message to add to the log.source
- The source of the message.public static void add(int type, String messageStr, Object source, Throwable exception)
type
- The type of message: TRACE, INFO, WARNING, ALARM, etc.messageStr
- The message to add to the log.source
- The source of the message.exception
- The exception that relates to the message.public static boolean printMessage(PrintWriter str, Date time, int type, String messageStr)
public static boolean printMessage(PrintWriter str, Date time, DateFormat dateFormat, int type, String messageStr)
public static boolean printMessage(PrintWriter logWriter, Date time, DateFormat dateFormat, int type, String messageStr, int maxLength)
logWriter
- The writer to print the message to.time
- The timestamp of the message.dateFormat
- The date format to use.type
- The type of message (log level).messageStr
- The content of the message.maxLength
- The maximum length the message can be.
public static String toLogString(LogEvent event)
public static void printException(PrintWriter str, Throwable exception)
public static boolean printExceptionMessage(PrintWriter str, Throwable exception, int maxLength)
public static void printExceptionTrace(PrintWriter str, Throwable exception, int maxLength)
str
- The output character stream.exception
- maxLength
- Max length of nested exception message, if any.public static void trace(String messageStr, Object source)
public static void trace(String messageStr, Object source, Throwable ex)
public static void warn(String messageStr, Object source)
public static void warn(String messageStr, Object source, Throwable ex)
public static void alarm(String messageStr, Object source)
public static void alarm(String messageStr, Object source, Throwable ex)
public static void info(String messageStr, Object source)
public static void internalError(String messageStr, Object source)
public static void internalError(String messageStr, Object source, Throwable ex)
public static void diagnostic(String messageStr, Object source)
public static void diagnostic(String messageStr, Object source, Throwable ex)
public static void removeLogListener(LogListener l)
public static void addLogListener(LogListener l)
protected static void fireMessageReceived(LogEvent e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |