Package eu.bandm.tools.message
Class MessagePrinter.Indenting<M extends Message>
java.lang.Object
eu.bandm.tools.message.MessagePrinter<M>
eu.bandm.tools.message.MessagePrinter.Indenting<M>
- All Implemented Interfaces:
MessageReceiver<M>
- Enclosing class:
MessagePrinter<M extends Message>
Specialization of
MessagePrinter
with addtional features.
- indenting of messages according to
Message.Kind.logStart
andMessage.Kind.logEnd
- a
SimpleMessage.Ping
message is printed as a single character without line feed, for progress indication. - colors can be set to highlight errors and warnings.
- the time between a logstart and corresponding logend can be printed
Error, warning and hint messages are not indented, for not disturbing their recognition by a parser, e.g. by XEmac's "next-error" function.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.bandm.tools.message.MessagePrinter
MessagePrinter.Indenting<M extends Message>
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
Terminal escape sequence to end the printing of critical errros.protected String
Terminal escape sequence to end the printing of warnings.protected String
Terminal escape sequence to start the printing of critical errros.protected String
Terminal escape sequence to start the printing of warnings.static final String
default value for the indent string, is "| ".static final String
default value for the ping string, is ".".protected final String
String used to show the current indentation level.protected int
Local storage for the current nesting level.protected final String
String given out when receiving aSimpleMessage.Ping
message.protected boolean
Whether stack traces shall be printed.Memorizes the time stamp for an incomingMessage.Kind.logStart
Translating the correspondingMessage.Kind.logStart
andMessage.Kind.logEnd
messages to the same key.protected boolean
Local storage whether the last message received was aSimpleMessage.Ping
.Fields inherited from class eu.bandm.tools.message.MessagePrinter
out, toStr
-
Constructor Summary
ConstructorDescriptionTakes default values for indent and ping string, behaves likethe super constructor
.Indenting
(OutputStream os, String ps, String is, boolean sst) Takes explitly values for ping string and indent string.Indenting
(PrintWriter out) Takes default values for indent and ping string, behaves likethe super constructor
.Indenting
(PrintWriter out, String ps, String is, boolean sst) Constructor which takes explitly values for ping string and indent string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Receive a message, format its text and arguments, and send the text result to the drainMessagePrinter.out
.void
setCriticalColor
(@Opt String colorStartCritical, @Opt String colorEndCritical) Sets the terminal escape sequences for starting and ending the printing of a critical message (error or failure, etc).void
setShowStackTraces
(boolean sst) Whether the stack traces ofMessage.cause
shall be printed.void
setWarningColor
(@Opt String colorStartWarning, @Opt String colorEndWarning) Sets the terminal escape sequences for starting and ending the printing of a warning message.Methods inherited from class eu.bandm.tools.message.MessagePrinter
setMessageToString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.message.MessageReceiver
ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse
-
Field Details
-
pingString
String given out when receiving aSimpleMessage.Ping
message. -
indentString
String used to show the current indentation level. -
showStackTraces
protected boolean showStackTracesWhether stack traces shall be printed. -
colorStartCritical
Terminal escape sequence to start the printing of critical errros. -
colorEndCritical
Terminal escape sequence to end the printing of critical errros. -
colorStartWarning
Terminal escape sequence to start the printing of warnings. -
colorEndWarning
Terminal escape sequence to end the printing of warnings. -
wasPing
protected boolean wasPingLocal storage whether the last message received was aSimpleMessage.Ping
. -
level
protected int levelLocal storage for the current nesting level. -
timingKey
Translating the correspondingMessage.Kind.logStart
andMessage.Kind.logEnd
messages to the same key. (ForSimpleMessage
this would be "m->m.getText()
"). When set != null, the timing information will be printed. -
startTime
Memorizes the time stamp for an incomingMessage.Kind.logStart
-
DEFAULT_INDENT_STRING
default value for the indent string, is "| ".- See Also:
-
DEFAULT_PING_STRING
default value for the ping string, is ".".- See Also:
-
-
Constructor Details
-
Indenting
Takes default values for indent and ping string, behaves likethe super constructor
.- Parameters:
os
- the target of all text output
-
Indenting
Takes default values for indent and ping string, behaves likethe super constructor
.- Parameters:
out
- the target of all text output
-
Indenting
Takes explitly values for ping string and indent string. Apart from that it behaves likethe super constructor
.- Parameters:
os
- the target of all text outputps
- the string to write a "Ping" to output.is
- the string to make indentation for log-message nesting.sst
- whether to show stack traces in of error messages.
-
Indenting
Constructor which takes explitly values for ping string and indent string. Apart from that behaves likethe super constructor
.- Parameters:
out
- the target of all text outputps
- the string to write a "Ping" to output.is
- the string to make indentation for log-message nesting.sst
- whether to show stack traces in of error messages.
-
-
Method Details
-
setShowStackTraces
public void setShowStackTraces(boolean sst) Whether the stack traces ofMessage.cause
shall be printed.- Parameters:
sst
- new value of that flag.
-
setCriticalColor
public void setCriticalColor(@Opt @Opt String colorStartCritical, @Opt @Opt String colorEndCritical) Sets the terminal escape sequences for starting and ending the printing of a critical message (error or failure, etc). Null inputs are permitted and mean empty strings.- Parameters:
colorStartCritical
- the terminal control string to switch to a critical warning color.colorEndCritical
- the terminal control string to switch back from critical warning color to normal color.
-
setWarningColor
Sets the terminal escape sequences for starting and ending the printing of a warning message. Null inputs are permitted and mean empty strings.- Parameters:
colorStartWarning
- the terminal control string to switch to a critical warning color.colorEndWarning
- the terminal control string to switch back from critical warning color to normal color.
-
receive
Receive a message, format its text and arguments, and send the text result to the drainMessagePrinter.out
. Possibly color-change terminal command strings are sent.- Specified by:
receive
in interfaceMessageReceiver<M extends Message>
- Overrides:
receive
in classMessagePrinter<M extends Message>
- Parameters:
message
- the message to vsualizs.
-