public LogRecord toLog(String line) {
        if (line.length() > 1 << 13)
            line = line.substring(0, 1 << 13) + " ... (" + (line.length() - (1 << 13)) + " more bytes truncated)";

        buffer.reset();
        try (PrintStream formatter = new PrintStream(new HtmlAnsiOutputStream(buffer))) {
            formatter.print(line);
        }
        return new LogRecord(HTML, buffer.toString(UTF_8));
    }
Converts ANSI output to HTML-safe log records

@author jonmv
vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/HtmlLogger.java