com.vlkan.hrrs.replayer.jtl.JtlFilePrinter Maven / Gradle / Ivy
package com.vlkan.hrrs.replayer.jtl;
import com.vlkan.hrrs.replayer.cli.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import static com.google.common.base.Preconditions.checkNotNull;
public class JtlFilePrinter implements JtlPrinter {
private static final Logger LOGGER = LoggerFactory.getLogger(JtlFilePrinter.class);
private final PrintStream printStream;
public JtlFilePrinter(Config config) throws FileNotFoundException {
checkNotNull(config, "config");
FileOutputStream outputStream = new FileOutputStream(config.getJtlOutputFile());
this.printStream = new PrintStream(outputStream);
printStream.println("");
printStream.println("");
LOGGER.debug("instantiated (file={})", config.getJtlOutputFile());
}
@Override
public void print(long timestampMillis, String label, int statusCode, long latency, String threadName) {
String entry = String.format(
"",
latency,
latency,
timestampMillis,
(statusCode & 200) == 200,
statusCode,
label,
threadName);
synchronized (this) {
printStream.println(entry);
}
}
@Override
public synchronized void close() {
LOGGER.debug("closing");
printStream.println(" ");
printStream.close();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy