"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.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).

LoggerFilterOutputStream.java  (apache-log4j-2.11.1-src):LoggerFilterOutputStream.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.FilterOutputStream; import java.io.FilterOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
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.InternalFilterOutputStream;
import org.apache.logging.log4j.spi.ExtendedLogger; import org.apache.logging.log4j.spi.ExtendedLogger;
/** /**
* Logs each line written to a pre-defined level. Can also be configured with a Marker. This class provides an interface * Logs each line written to a pre-defined level. Can also be configured with a Marker. This class provides an interface
* that follows the {@link java.io.OutputStream} methods in spirit, but doesn't require output to any external stream. * that follows the {@link java.io.OutputStream} methods in spirit, but doesn't require output to any external stream.
* This class should <em>not</em> be used as a stream for an underlying logger u nless it's being used as a bridge. * This class should <em>not</em> be used as a stream for an underlying logger u nless it's being used as a bridge.
* Otherwise, infinite loops may occur! * Otherwise, infinite loops may occur!
* *
* @since 2.1 * @since 2.1
*/ */
public class LoggerFilterOutputStream extends FilterOutputStream { public class LoggerFilterOutputStream extends FilterOutputStream {
private static final String FQCN = LoggerFilterOutputStream.class.getName(); private static final String FQCN = LoggerFilterOutputStream.class.getName();
private final ByteStreamLogger logger; private final InternalFilterOutputStream logger;
private final String fqcn;
protected LoggerFilterOutputStream(final OutputStream out, final Charset cha rset, final ExtendedLogger logger, protected LoggerFilterOutputStream(final OutputStream out, final Charset cha rset, final ExtendedLogger logger,
final String fqcn, final Level level, fin al Marker marker) { final String fqcn, final Level level, fin al Marker marker) {
super(out); super(out);
this.logger = new ByteStreamLogger(logger, level, marker, charset); this.logger = new InternalFilterOutputStream(out, charset, logger, fqcn
this.fqcn = fqcn == null ? FQCN : fqcn; == null ? FQCN : fqcn,
level, marker);
} }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
this.out.close(); this.logger.close();
this.logger.close(this.fqcn);
} }
@Override @Override
public void flush() throws IOException { public void flush() throws IOException {
this.out.flush(); this.logger.flush();
} }
@Override @Override
public String toString() { public String toString() {
return LoggerFilterOutputStream.class.getSimpleName() + "{stream=" + thi s.out + '}'; return LoggerFilterOutputStream.class.getSimpleName() + logger.toString( );
} }
@Override @Override
public void write(final byte[] b) throws IOException { public void write(final byte[] b) throws IOException {
this.out.write(b); this.logger.write(b);
this.logger.put(this.fqcn, b, 0, b.length);
} }
@Override @Override
public void write(final byte[] b, final int off, final int len) throws IOExc eption { public void write(final byte[] b, final int off, final int len) throws IOExc eption {
this.out.write(b, off, len); this.logger.write(b, off, len);
this.logger.put(this.fqcn, b, off, len);
} }
@Override @Override
public void write(final int b) throws IOException { public void write(final int b) throws IOException {
this.out.write(b); this.logger.write(b);
this.logger.put(this.fqcn, (byte) (b & 0xFF));
} }
} }
 End of changes. 9 change blocks. 
14 lines changed or deleted 11 lines changed or added

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