"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

LoggerInputStream.java  (apache-log4j-2.11.1-src):LoggerInputStream.java  (apache-log4j-2.11.2-src)
skipping to change at line 27 skipping to change at line 27
package org.apache.logging.log4j.io; package org.apache.logging.log4j.io;
import java.io.FilterInputStream; import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.io.internal.InternalInputStream;
import org.apache.logging.log4j.spi.ExtendedLogger; import org.apache.logging.log4j.spi.ExtendedLogger;
/** /**
* Logs each line read to a pre-defined level. Can also be configured with a Mar ker. * Logs each line read to a pre-defined level. Can also be configured with a Mar ker.
* *
* @since 2.1 * @since 2.1
*/ */
public class LoggerInputStream extends FilterInputStream { public class LoggerInputStream extends FilterInputStream {
private static final String FQCN = LoggerInputStream.class.getName(); private static final String FQCN = LoggerInputStream.class.getName();
private final String fqcn; private final InternalInputStream logger;
private final ByteStreamLogger logger;
protected LoggerInputStream(final InputStream in, final Charset charset, fin al ExtendedLogger logger, protected LoggerInputStream(final InputStream in, final Charset charset, fin al ExtendedLogger logger,
final String fqcn, final Level level, final Mark er marker) { final String fqcn, final Level level, final Mark er marker) {
super(in); super(in);
this.logger = new ByteStreamLogger(logger, level, marker, charset); this.logger = new InternalInputStream(in, charset, logger, fqcn == null
this.fqcn = fqcn == null ? FQCN : fqcn; ? FQCN : fqcn, level, marker);
} }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
this.logger.close(this.fqcn); this.logger.close();
super.close();
} }
@Override @Override
public int read() throws IOException { public int read() throws IOException {
final int b = super.read(); return logger.read();
this.logger.put(this.fqcn, b);
return b;
} }
@Override @Override
public int read(final byte[] b) throws IOException { public int read(final byte[] b) throws IOException {
return read(b, 0, b.length); return logger.read(b);
} }
@Override @Override
public int read(final byte[] b, final int off, final int len) throws IOExcep tion { public int read(final byte[] b, final int off, final int len) throws IOExcep tion {
final int bytesRead = super.read(b, off, len); return logger.read(b, off, len);
this.logger.put(this.fqcn, b, off, bytesRead);
return bytesRead;
} }
@Override @Override
public String toString() { public String toString() {
return LoggerInputStream.class.getSimpleName() + "{stream=" + this.in + '}'; return LoggerInputStream.class.getSimpleName() + logger.toString();
} }
} }
 End of changes. 8 change blocks. 
14 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)