code: public void addLogMessageConsumer(Consumer<String> consumer) {
          checkNotNull(consumer, "consumer parameter is NULL!");
          addOutPutStream(new OutputStream() {
              StringBuilder lineBuilder = new StringBuilder();
  
              @Override
              public void write(int chr) {
                  try {
                      lineBuilder.append((char) chr);
                      Matcher matcher = LOG_MESSAGE_PATTERN.matcher(lineBuilder.toString());
                      if (matcher.matches()) {
                          consumer.accept(matcher.group(1));
                          lineBuilder = new StringBuilder();
                      }
                  } catch (Exception e) {
                      // log error and continue
                      LOG.warn("Log message consumer crashed!", e);
                  }
              }
          });
      }
docs: When a complete log message is available (from server output data), the
  specified {@code Consumer} is invoked with that log message.
  
  <p>NOTE: You might want to call method {@link #clearOutPutStreams()} before
  calling this method.
  
  <p>If the Consumer fails and throws an exception the exception is logged (at
  WARN level) and execution continues.
  <br>
  
  @param consumer
  Consumer block to be executed when a log message is available.