Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
Java
at main
123456789101112131415161718192021222324252627282930313233package com.microchip.mplab.ipecmd.errorlog;
import java.io.ByteArrayOutputStream;import java.io.IOException;import java.util.logging.Level;import java.util.logging.Logger;
public class LoggingOutputStream extends ByteArrayOutputStream { private String lineSeparator; private Logger logger; private Level level;
public LoggingOutputStream(Logger logger, Level level) { this.logger = logger; this.level = level; this.lineSeparator = System.getProperty("line.separator"); }
@Override public void flush() throws IOException { String record; synchronized (this) { super.flush(); record = this.toString(); super.reset(); }
if (record.length() != 0 && !record.equals(this.lineSeparator)) { this.logger.logp(this.level, "", "", record); } }}