/** * Creates an output stream filter built on top of the specified * underlying output stream. * * @param out the underlying output stream. * @param logger log trace here */ public TraceOutputStream(OutputStream out, MailLogger logger) { super(out); this.trace = logger.isLoggable(Level.FINEST); this.traceOut = new LogOutputStream(logger);; }
public void write(int b) throws IOException { if (!logger.isLoggable(level)) return; if (b == '\r') { logBuf(); } else if (b == '\n') { if (lastb != '\r') logBuf(); } else { expandCapacity(1); buf[pos++] = (byte)b; } lastb = b; }
/** * Convert the buffer to a string and log it. */ private void logBuf() { String msg = new String(buf, 0, pos); pos = 0; log(msg); }
@Override public void write(byte b[]) throws IOException { write(b, 0, b.length); }
public void write(byte b[]) throws IOException { write(b, 0, b.length); }
@Override public void write(int b) throws IOException { if (!logger.isLoggable(level)) return; if (b == '\r') { logBuf(); } else if (b == '\n') { if (lastb != '\r') logBuf(); } else { expandCapacity(1); buf[pos++] = (byte)b; } lastb = b; }
/** * Creates an input stream filter built on top of the specified * input stream. * * @param in the underlying input stream. * @param logger log trace here */ public TraceInputStream(InputStream in, MailLogger logger) { super(in); this.trace = logger.isLoggable(Level.FINEST); this.traceOut = new LogOutputStream(logger); }
/** * Convert the buffer to a string and log it. */ private void logBuf() { String msg = new String(buf, 0, pos); pos = 0; log(msg); }
@Override public void write(byte b[]) throws IOException { write(b, 0, b.length); }
public void write(byte b[], int off, int len) throws IOException { int start = off; if (!logger.isLoggable(level)) return; len += off; for (int i = start; i < len ; i++) { if (b[i] == '\r') { expandCapacity(i - start); System.arraycopy(b, start, buf, pos, i - start); pos += i - start; logBuf(); start = i + 1; } else if (b[i] == '\n') { if (lastb != '\r') { expandCapacity(i - start); System.arraycopy(b, start, buf, pos, i - start); pos += i - start; logBuf(); } start = i + 1; } lastb = b[i]; } if ((len - start) > 0) { expandCapacity(len - start); System.arraycopy(b, start, buf, pos, len - start); pos += len - start; } }
/** * Creates an input stream filter built on top of the specified * input stream. * * @param in the underlying input stream. * @param logger log trace here */ public TraceInputStream(InputStream in, MailLogger logger) { super(in); this.trace = logger.isLoggable(Level.FINEST); this.traceOut = new LogOutputStream(logger); }
/** * Convert the buffer to a string and log it. */ private void logBuf() { String msg = new String(buf, 0, pos); pos = 0; log(msg); }
@Override public void write(byte b[]) throws IOException { write(b, 0, b.length); }
for (int i = start; i < len ; i++) { if (b[i] == '\r') { expandCapacity(i - start); System.arraycopy(b, start, buf, pos, i - start); pos += i - start; logBuf(); start = i + 1; } else if (b[i] == '\n') { if (lastb != '\r') { expandCapacity(i - start); System.arraycopy(b, start, buf, pos, i - start); pos += i - start; logBuf(); expandCapacity(len - start); System.arraycopy(b, start, buf, pos, len - start); pos += len - start;
/** * Creates an output stream filter built on top of the specified * underlying output stream. * * @param out the underlying output stream. * @param logger log trace here */ public TraceOutputStream(OutputStream out, MailLogger logger) { super(out); this.trace = logger.isLoggable(Level.FINEST); this.traceOut = new LogOutputStream(logger);; }
/** * Convert the buffer to a string and log it. */ private void logBuf() { String msg = new String(buf, 0, pos); pos = 0; log(msg); }
@Override public void write(byte b[]) throws IOException { write(b, 0, b.length); }
@Override public void write(int b) throws IOException { if (!logger.isLoggable(level)) return; if (b == '\r') { logBuf(); } else if (b == '\n') { if (lastb != '\r') logBuf(); } else { expandCapacity(1); buf[pos++] = (byte)b; } lastb = b; }
/** * Creates an output stream filter built on top of the specified * underlying output stream. * * @param out the underlying output stream. * @param logger log trace here */ public TraceOutputStream(OutputStream out, MailLogger logger) { super(out); this.trace = logger.isLoggable(Level.FINEST); this.traceOut = new LogOutputStream(logger);; }
/** * Convert the buffer to a string and log it. */ private void logBuf() { String msg = new String(buf, 0, pos); pos = 0; log(msg); }