Package rma.util.logging
Class CustomFormatter
java.lang.Object
java.util.logging.Formatter
rma.util.logging.CustomFormatter
- Direct Known Subclasses:
StackFilteringFormatter
A
Formatter that may be customized in a logging.properties file. The syntax of the property
rma.util.logging.CustomFormatter.format specifies the output. A newline will be appended to the string and the
following special characters will be expanded (case sensitive):-
%m- message%L- log level%n- name of the logger%t- a timestamp (in ISO-8601 "yyyy-MM-dd HH:mm:ss.SSS" format)%M- source method name (if available, otherwise "?")%c- source class name (if available, otherwise "?")%C- source simple class name (if available, otherwise "?")%T- thread ID%E- (Filename.java:linenumber) Slow to generate Eclipse format
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected static final StackTraceElementprotected static final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBufferappendEclipseFormat(StackTraceElement element, StringBuffer sb) Appends the filename and line number to the provided StringBuffer.static StackTraceElementfindCallingElement(Throwable newThrowable, int depth) formatMessage(LogRecord record, StringBuffer result) Localize and format the message string from a log record.getEclipseFormat(LogRecord logRecord, StringBuffer sb) Returns caller location information in eclipse format eg (Filename.java:23) WARNING Generating caller location information is slow.static intgetStackTraceDepth(Throwable newThrowable) static StackTraceElementgetStackTraceElement(Throwable newThrowable, int depth) protected StringBuffergetThrowableMessage(LogRecord record, StringBuffer sb) static booleanMethods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
Field Details
-
DATE_FORMAT
- See Also:
-
DEFAULT_FORMAT
- See Also:
-
nullElement
-
useReflective
protected static final boolean useReflective
-
-
Constructor Details
-
CustomFormatter
public CustomFormatter()
-
-
Method Details
-
format
-
formatMessage
Localize and format the message string from a log record.The message string is first localized to a format string using the record's ResourceBundle. (If there is no ResourceBundle, or if the message key is not found, then the key is used as the format string.) The format String uses java.text style formatting.
- If there are no parameters, no formatter is used.
- Otherwise, if the string contains "{0" then java.text.MessageFormat is used to format the string.
- Otherwise no formatting is performed.
- Parameters:
record- the log record containing the raw messageresult- the StringBuffer where the message text is to be appended- Returns:
- StringBuffer where the message text was appended
-
getThrowableMessage
-
getEclipseFormat
Returns caller location information in eclipse format eg (Filename.java:23) WARNING Generating caller location information is slow. It's use should be avoided unless execution speed is not an issue.- Parameters:
sb-- Returns:
- the eclipse format
-
appendEclipseFormat
Appends the filename and line number to the provided StringBuffer. Chaining together the append calls was found (via testing) to be faster.- Parameters:
element-sb-- Returns:
-
findCallingElement
-
getStackTraceDepth
public static int getStackTraceDepth(Throwable newThrowable) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException -
getStackTraceElement
-
useReflection
public static boolean useReflection()
-