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>
public static class MessagePrinter.Indenting<M extends Message> extends MessagePrinter<M>
Specialization ofMessagePrinter
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
Fields Modifier and Type Field Description protected java.lang.String
color_endCritical
Terminal escape sequence to end the printing of critical errros.protected java.lang.String
color_endWarning
Terminal escape sequence to end the printing of warnings.protected java.lang.String
color_startCritical
Terminal escape sequence to start the printing of critical errros.protected java.lang.String
color_startWarning
Terminal escape sequence to start the printing of warnings.static java.lang.String
DEFAULT_INDENT_STRING
default value for the indent string, is "| ".static java.lang.String
DEFAULT_PING_STRING
default value for the ping string, is ".".protected java.lang.String
indentString
String used to show the current indentation level.protected int
level
Local storage for the current nesting levelprotected java.lang.String
pingString
String given out when receiving aSimpleMessage.Ping
message.protected boolean
showStackTraces
Whether stack traces shall be printed.protected java.util.Map<java.lang.Object,java.lang.Long>
startTime
Memorizes the time stamp for an incomingMessage.Kind.logStart
protected @Opt java.util.function.Function<Message,java.lang.Object>
timingKey
Translating the correspondingMessage.Kind.logstart
andMessage.Kind.logend
messages to the same key.protected boolean
wasPing
Local storage whether the last message received was aSimpleMessage.Ping
.-
Fields inherited from class eu.bandm.tools.message.MessagePrinter
out, toStr
-
-
Constructor Summary
Constructors Constructor Description Indenting(java.io.OutputStream os)
Takes default values for indent and ping string, behaves likethe super constructor
.Indenting(java.io.OutputStream os, java.lang.String ps, java.lang.String is, boolean sst)
Takes explitly values for ping string and indent string.Indenting(java.io.PrintWriter out)
Takes default values for indent and ping string, behaves likethe super constructor
.Indenting(java.io.PrintWriter out, java.lang.String ps, java.lang.String is, boolean sst)
constructor which takes explitly values for ping string and indent string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
receive(M message)
Receive a message, format it and send it to the drainMessagePrinter.out
void
setColors_vt100()
Sets the colors for the error messages and warnings for a VT 100 terminal.void
setCriticalColor(@Opt java.lang.String color_startCritical, @Opt java.lang.String color_endCritical)
Sets the terminal escape sequences for starting and ending the printing of a critical message (error or failure, etc).void
setCriticalColor_vt100()
Sets the colors for the error messages for a VT 100 terminal.void
setShowStackTraces(boolean sst)
Whether the stack traces ofMessage.cause
shall be printed.void
setWarningColor(@Opt java.lang.String color_startWarning, @Opt java.lang.String color_endWarning)
Sets the terminal escape sequences for starting and ending the printing of a critical message (error or failure, etc).-
Methods inherited from class eu.bandm.tools.message.MessagePrinter
setMessageToString
-
-
-
-
Field Detail
-
pingString
protected final java.lang.String pingString
String given out when receiving aSimpleMessage.Ping
message.
-
indentString
protected final java.lang.String indentString
String used to show the current indentation level.
-
showStackTraces
protected boolean showStackTraces
Whether stack traces shall be printed.
-
color_startCritical
protected java.lang.String color_startCritical
Terminal escape sequence to start the printing of critical errros.
-
color_endCritical
protected java.lang.String color_endCritical
Terminal escape sequence to end the printing of critical errros.
-
color_startWarning
protected java.lang.String color_startWarning
Terminal escape sequence to start the printing of warnings.
-
color_endWarning
protected java.lang.String color_endWarning
Terminal escape sequence to end the printing of warnings.
-
wasPing
protected boolean wasPing
Local storage whether the last message received was aSimpleMessage.Ping
.
-
level
protected int level
Local storage for the current nesting level
-
timingKey
@Opt protected @Opt java.util.function.Function<Message,java.lang.Object> 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
protected java.util.Map<java.lang.Object,java.lang.Long> startTime
Memorizes the time stamp for an incomingMessage.Kind.logStart
-
DEFAULT_INDENT_STRING
public static final java.lang.String DEFAULT_INDENT_STRING
default value for the indent string, is "| ".- See Also:
- Constant Field Values
-
DEFAULT_PING_STRING
public static final java.lang.String DEFAULT_PING_STRING
default value for the ping string, is ".".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Indenting
public Indenting(java.io.OutputStream os)
Takes default values for indent and ping string, behaves likethe super constructor
.
-
Indenting
public Indenting(java.io.PrintWriter out)
Takes default values for indent and ping string, behaves likethe super constructor
.
-
Indenting
public Indenting(java.io.OutputStream os, java.lang.String ps, java.lang.String is, boolean sst)
Takes explitly values for ping string and indent string. Apart from that it behaves likethe super constructor
.
-
Indenting
public Indenting(java.io.PrintWriter out, java.lang.String ps, java.lang.String is, boolean sst)
constructor which takes explitly values for ping string and indent string. Apart from that behaves likethe super constructor
.
-
-
Method Detail
-
setShowStackTraces
public void setShowStackTraces(boolean sst)
Whether the stack traces ofMessage.cause
shall be printed.
-
setCriticalColor
public void setCriticalColor(@Opt @Opt java.lang.String color_startCritical, @Opt @Opt java.lang.String color_endCritical)
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.
-
setWarningColor
public void setWarningColor(@Opt @Opt java.lang.String color_startWarning, @Opt @Opt java.lang.String color_endWarning)
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.
-
setCriticalColor_vt100
public void setCriticalColor_vt100()
Sets the colors for the error messages for a VT 100 terminal.
-
setColors_vt100
public void setColors_vt100()
Sets the colors for the error messages and warnings for a VT 100 terminal.
-
receive
public void receive(M message)
Receive a message, format it and send it to the drainMessagePrinter.out
- Specified by:
receive
in interfaceMessageReceiver<M extends Message>
- Overrides:
receive
in classMessagePrinter<M extends Message>
-
-