|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--grace.log.EventFormat
This class simply captures all of the formatting functionality into a class rather than have it in a specific Handler. This is to allow any Handler classes to format all or portions of Event text even though the PrintHandler class is the only class producing purely textual output.
Typically, a Handler, such as PrintHandler, will instantiate an EventFormat for each different format it needs to support. In the case of PrintHandler, this is only one. Then, the Handler calls the format(Event) function each time it wants to format an event.
public void log(Event event) { EventFormat format = new EventFormat(); System.out.println(format.format(event)); }
event-format is composed of a concatenation of the following items:
time-format is one of the following:
relative-time-format is one of the following:
thread-format is:
%g.%g
where the '.', which can be any
character, will be used to delimit each thread group name.
class-format is:
filename-format is:
message-format is:
object-format is:
exception-format is:
"%t(%r):%n: %e: %c.%f:%l: %m: %o\n"
Field Summary | |
static java.lang.String |
BLACK
|
static java.lang.String |
BLACK_BACKGROUND
|
static java.lang.String |
BLUE
|
static java.lang.String |
BLUE_BACKGROUND
|
static java.lang.String |
BRIGHT
|
static java.lang.String |
CYAN
|
static java.lang.String |
CYAN_BACKGROUND
|
static char |
ESC
|
static java.lang.String |
GREEN
|
static java.lang.String |
GREEN_BACKGROUND
|
static java.lang.String |
HIGHLIGHT
|
static java.lang.String |
NO_COLOR
|
static java.lang.String |
PLAIN
|
static java.lang.String |
PURPLE
|
static java.lang.String |
PURPLE_BACKGROUND
|
static java.lang.String |
rcsid
|
static java.lang.String |
RED
|
static java.lang.String |
RED_BACKGROUND
|
static java.lang.String |
UNDERLINE
|
static java.lang.String |
WHITE
|
static java.lang.String |
WHITE_BACKGROUND
|
static java.lang.String |
YELLOW
|
static java.lang.String |
YELLOW_BACKGROUND
|
Constructor Summary | |
EventFormat()
This constructs an EventFormat with the default formatting. |
|
EventFormat(java.lang.String format)
This constructs an EventFormat with custom formatting. |
Method Summary | |
java.lang.String |
colorListToColor(java.lang.String colorList)
Takes a space separated list of string colors and returns a composite color that can be used to set any elements color of this class. |
protected java.lang.String |
eliminateEndingNewlines(java.lang.String source)
|
protected static java.lang.String |
expandSpecialChars(java.lang.String string)
This expands newlines and tab escapes into the actual character. |
java.lang.String |
format(Event event)
This converts and returns the given event as a
String using a default format or the format set in the
EventFormat constructor. |
protected void |
formatException(java.lang.StringBuffer buffer,
java.lang.Exception exception)
This formats the given exception. |
protected void |
formatFormattedObject(java.lang.String subFormat,
java.lang.StringBuffer buffer,
java.lang.String name,
java.lang.Object object)
This function writes the given object to the given buffer using the grace.io.JavaPrintWriter. |
protected void |
formatGenericObject(java.lang.StringBuffer buffer,
java.lang.String subFormat,
java.lang.String name,
java.lang.Object object)
This function writes the given object to the given buffer using the given format string. |
protected void |
formatMessage(java.lang.StringBuffer buffer,
java.lang.String subFormat,
java.lang.String message)
This formats a string representation of the given message. |
protected void |
formatObject(java.lang.StringBuffer buffer,
java.lang.String format,
java.lang.String message,
java.lang.Object object)
This formats a string representation of the given object. |
protected void |
formatRelativeTime(java.lang.StringBuffer buffer,
java.lang.String subFormat,
java.util.Date now)
This writes the difference in time between now and
the start of the application to the given buffer format. |
protected void |
formatThreadName(java.lang.StringBuffer buffer,
java.lang.String subFormat,
java.util.Vector names)
This writes the given Vector of names to the given buffer assuming the format contains thread name escapes. |
protected void |
formatTime(java.lang.StringBuffer buffer,
java.lang.String subFormat,
java.util.Date now)
This returns a string representation of the current time, formatted according to the previously configured system properties. |
protected static java.text.DateFormat |
getDateFormat(java.lang.String name)
Utility function used by formatTime(...) to find
and return java.text.DateFormat for the given name. |
void |
setClassnameColor(java.lang.String color)
Sets the color of the formatted classname. |
void |
setEventColor(java.lang.String eventType,
java.lang.String color)
Sets color used to print the given event string in each log line. |
void |
setExceptionColor(java.lang.String color)
Sets the color of the formatted exception. |
void |
setExceptionFormat(java.lang.String format)
|
void |
setFunctionColor(java.lang.String color)
Sets the color of the formatted function. |
void |
setLineColor(java.lang.String event,
java.lang.String color)
Sets color used to print an entire log line whose event type is the given event string. |
void |
setMessageColor(java.lang.String color)
Sets the color of the formatted message. |
void |
setMessageFormat(java.lang.String format)
|
void |
setObjectColor(java.lang.String color)
Sets the color of the formatted object. |
void |
setObjectFormat(java.lang.String format)
|
void |
setObjectTimeFormat(java.text.DateFormat format)
|
void |
setRelativeTimeColor(java.lang.String color)
Sets the color of the formatted relative time. |
void |
setRelativeTimeFormat(java.lang.String format)
|
void |
setThreadColor(java.lang.String color)
Sets the color of the formatted thread. |
void |
setThreadFormat(java.lang.String format)
|
void |
setTimeColor(java.lang.String color)
Sets the color of the formatted time. |
void |
setTimeFormat(java.text.DateFormat format)
|
void |
useColors(boolean colors)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String rcsid
public static final java.lang.String NO_COLOR
public static final char ESC
public static final java.lang.String PLAIN
public static final java.lang.String BRIGHT
public static final java.lang.String UNDERLINE
public static final java.lang.String HIGHLIGHT
public static final java.lang.String BLACK
public static final java.lang.String RED
public static final java.lang.String GREEN
public static final java.lang.String YELLOW
public static final java.lang.String BLUE
public static final java.lang.String PURPLE
public static final java.lang.String CYAN
public static final java.lang.String WHITE
public static final java.lang.String BLACK_BACKGROUND
public static final java.lang.String RED_BACKGROUND
public static final java.lang.String GREEN_BACKGROUND
public static final java.lang.String YELLOW_BACKGROUND
public static final java.lang.String BLUE_BACKGROUND
public static final java.lang.String PURPLE_BACKGROUND
public static final java.lang.String CYAN_BACKGROUND
public static final java.lang.String WHITE_BACKGROUND
Constructor Detail |
public EventFormat()
Log
public EventFormat(java.lang.String format)
Log
Method Detail |
public java.lang.String format(Event event)
event
as a
String using a default format or the format set in the
EventFormat constructor.
This function parses the format:
event
- to convert into a String using the set formatprotected void formatException(java.lang.StringBuffer buffer, java.lang.Exception exception)
This function parses the format:
This needs work.
protected java.lang.String eliminateEndingNewlines(java.lang.String source)
protected void formatMessage(java.lang.StringBuffer buffer, java.lang.String subFormat, java.lang.String message)
This function parses the format:
buffer
- to which to write objectformat
- from which to format this objectmessage
- object to formatprotected void formatFormattedObject(java.lang.String subFormat, java.lang.StringBuffer buffer, java.lang.String name, java.lang.Object object)
buffer
- to which this function should appendobject
- to append to buffername
- value's name (should never be null)pretty
- flag given to JavaPrintWriter to control length of outputprotected void formatGenericObject(java.lang.StringBuffer buffer, java.lang.String subFormat, java.lang.String name, java.lang.Object object)
This function parses the format:
buffer
- to which this function should appendformat
- containing text and escape sequencesname
- value's name (should never be null)object
- to append to bufferprotected void formatObject(java.lang.StringBuffer buffer, java.lang.String format, java.lang.String message, java.lang.Object object)
buffer
- to which to write objectformat
- from which to format this objectmessage
- to use as value's name (should never be null)object
- object to formatprotected void formatThreadName(java.lang.StringBuffer buffer, java.lang.String subFormat, java.util.Vector names)
This function parses the format:
buffer
- to which the names will be writtenformat
- containing thread name escape sequencesnames
- to be written to buffer according to formatprotected void formatRelativeTime(java.lang.StringBuffer buffer, java.lang.String subFormat, java.util.Date now)
now
and
the start of the application to the given buffer
format.
This function parses the format:
buffer
- to which the relative time will be writtenformat
- containing relative time format instructionsnow
- from which the application start time is subtracted
to form the differenceprotected void formatTime(java.lang.StringBuffer buffer, java.lang.String subFormat, java.util.Date now)
This function parses the format:
protected static java.text.DateFormat getDateFormat(java.lang.String name)
formatTime(...)
to find
and return java.text.DateFormat for the given name.name
- { short, medium, long, full, protected static java.lang.String expandSpecialChars(java.lang.String string)
string
- containing potential escaped newlines and tabspublic void setObjectFormat(java.lang.String format)
public void setObjectTimeFormat(java.text.DateFormat format)
public void setTimeFormat(java.text.DateFormat format)
public void setRelativeTimeFormat(java.lang.String format)
public void setExceptionFormat(java.lang.String format)
public void setMessageFormat(java.lang.String format)
public void setThreadFormat(java.lang.String format)
public void useColors(boolean colors)
public java.lang.String colorListToColor(java.lang.String colorList)
public void setTimeColor(java.lang.String color)
public void setRelativeTimeColor(java.lang.String color)
public void setExceptionColor(java.lang.String color)
public void setMessageColor(java.lang.String color)
public void setObjectColor(java.lang.String color)
public void setThreadColor(java.lang.String color)
public void setClassnameColor(java.lang.String color)
public void setFunctionColor(java.lang.String color)
public void setEventColor(java.lang.String eventType, java.lang.String color)
event
- to print in colorcolor
- that can be a concatenation of constant colors in
this class.public void setLineColor(java.lang.String event, java.lang.String color)
event
- whose line to print in colorcolor
- that can be a concatenation of constant colors in
this class.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |