All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.t1.testcontainers.tools.StdoutLogConsumer Maven / Gradle / Ivy

The newest version!
package com.github.t1.testcontainers.tools;

import org.testcontainers.containers.output.OutputFrame;

import java.util.function.Consumer;

import static org.testcontainers.containers.output.OutputFrame.OutputType.STDOUT;

/**
 * A simple consumer for Testcontainers logs, printing the container's STDOUT in green and STDERR in blue,
 * both to the JVM stdout.
 */
public class StdoutLogConsumer implements Consumer {
    @Override public void accept(OutputFrame outputFrame) {
        String color = (outputFrame.getType() == STDOUT) ? GREEN : BLUE;
        System.out.print(color + outputFrame.getUtf8String() + RESET);
    }

    private static final String RESET = "\u001B[0m";
    private static final String BLUE = "\u001B[34m";
    private static final String GREEN = "\u001B[32m";
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy