Class SimpleLoggerOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public abstract class SimpleLoggerOutputStream
    extends AbstractLoggerOutputStream

    If you want to convert a SimpleLogger to a OutputStream this can be used. Every line appearing on the output stream will be logged using the supplied SimpleLogger.

    One use case is for example to convert lines output from some external command to events like so:

     
             CommandExecutorImpl oc = CommandExecutorImpl.builder()
               .executablesPaths("/usr/local/bin/oc")
               .build();
    
             oc.submit(SimpleLoggerOutputStream.info(EventSimpleLogger.of(
                 event -> {
                     if (event.getMessage().toString().contains("Forwarding from [::1]:" + jmxPort)) {
                         synchronized (container) {
                             container.ready = true;
                             container.notifyAll();
                         }
                     }
                 })),
                 "-n", "poms-stack-" + env, "port-forward", pod, jmxPort
             );