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 of MessagePrinter with addtional features.
  • indenting of messages according to Message.Kind.logStart and Message.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
The string values for indentation and pinging are defined at construction time.
Error, warning and hint messages are not indented, for not disturbing their recognition by a parser, e.g. by XEmac's "next-error" function.
  • Field Details

    • pingString

      protected final String pingString
      String given out when receiving a SimpleMessage.Ping message.
    • indentString

      protected final String indentString
      String used to show the current indentation level.
    • showStackTraces

      protected boolean showStackTraces
      Whether stack traces shall be printed.
    • color_startCritical

      protected String color_startCritical
      Terminal escape sequence to start the printing of critical errros.
    • color_endCritical

      protected String color_endCritical
      Terminal escape sequence to end the printing of critical errros.
    • color_startWarning

      protected String color_startWarning
      Terminal escape sequence to start the printing of warnings.
    • color_endWarning

      protected String color_endWarning
      Terminal escape sequence to end the printing of warnings.
    • wasPing

      protected boolean wasPing
      Local storage whether the last message received was a SimpleMessage.Ping.
    • level

      protected int level
      Local storage for the current nesting level
    • timingKey

      @Opt protected @Opt Function<Message,Object> timingKey
      Translating the corresponding Message.Kind.logStart and Message.Kind.logEnd messages to the same key. (For SimpleMessage this would be "m->m.getText()"). When set != null, the timing information will be printed.
    • startTime

      protected Map<Object,Long> startTime
      Memorizes the time stamp for an incoming Message.Kind.logStart
    • DEFAULT_INDENT_STRING

      public static final String DEFAULT_INDENT_STRING
      default value for the indent string, is "| ".
      See Also:
    • DEFAULT_PING_STRING

      public static final String DEFAULT_PING_STRING
      default value for the ping string, is ".".
      See Also:
  • Constructor Details

  • Method Details

    • setShowStackTraces

      public void setShowStackTraces(boolean sst)
      Whether the stack traces of Message.cause shall be printed.
    • setCriticalColor

      public void setCriticalColor(@Opt @Opt String color_startCritical, @Opt @Opt 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 String color_startWarning, @Opt @Opt 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.
    • receive

      public void receive(M message)
      Receive a message, format it and send it to the drain MessagePrinter.out
      Specified by:
      receive in interface MessageReceiver<M extends Message>
      Overrides:
      receive in class MessagePrinter<M extends Message>