/** * Flush this log stream. * * @see java.io.OutputStream#flush() */ @Override public void flush() { if (buffer.size() > 0) { processBuffer(); } }
/** * Logs a line to the log system of the user. * * @param line * the line to log. */ protected void processLine(final String line) { processLine(line, level); }
write(b[offset]); offset++; remaining--;
/** * Flush any pending data in the {@link #logBuffer} * * @throws IOException If closing the stream fails. */ @Override public void close() throws IOException { // first close the parent so we get all remaining data super.close(); // then ensure that any remaining buffer is logged synchronized (logBuffer) { if(logBuffer.length() > 0) { log.info(logBuffer.toString()); logBuffer.setLength(0); lastFlush = System.currentTimeMillis(); } } } }
/** * Writes all remaining data from the buffer. * * @see java.io.OutputStream#close() */ @Override public void close() throws IOException { if (buffer.size() > 0) { processBuffer(); } super.close(); }
/** * Converts the buffer to a string and sends it to {@code processLine}. */ protected void processBuffer() { processLine(buffer.toString()); buffer.reset(); }
/** * Write the data to the buffer and flush the buffer, if a line separator is * detected. * * @param cc data to log (byte). * @see java.io.OutputStream#write(int) */ @Override public void write(final int cc) throws IOException { final byte c = (byte) cc; if (c == '\n' || c == '\r') { if (!skip) { processBuffer(); } } else { buffer.write(cc); } skip = c == '\r'; }