"Fossies" - the Fresh Open Source Software Archive  

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

LoggerFilterWriter.java  (apache-log4j-2.11.1-src):LoggerFilterWriter.java  (apache-log4j-2.11.2-src)
skipping to change at line 26 skipping to change at line 26
*/ */
package org.apache.logging.log4j.io; package org.apache.logging.log4j.io;
import java.io.FilterWriter; import java.io.FilterWriter;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
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.InternalFilterWriter;
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.Writer} methods in spirit, but doesn't requir e output to any external out. * that follows the {@link java.io.Writer} methods in spirit, but doesn't requir e output to any external out.
* *
* @since 2.1 * @since 2.1
*/ */
public class LoggerFilterWriter extends FilterWriter { public class LoggerFilterWriter extends FilterWriter {
private static final String FQCN = LoggerFilterWriter.class.getName(); private static final String FQCN = LoggerFilterWriter.class.getName();
private final CharStreamLogger logger; private final InternalFilterWriter logger;
private final String fqcn;
protected LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final String fqcn, final Level level, protected LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final String fqcn, final Level level,
final Marker marker) { final Marker marker) {
super(out); super(out);
this.logger = new CharStreamLogger(logger, level, marker); this.logger = new InternalFilterWriter(out, logger, fqcn == null ? FQCN
this.fqcn = fqcn == null ? FQCN : 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 LoggerFilterWriter.class.getSimpleName() + "{writer=" + this.out + '}'; return LoggerFilterWriter.class.getSimpleName() + logger.toString();
} }
@Override @Override
public void write(final char[] cbuf) throws IOException { public void write(final char[] cbuf) throws IOException {
this.out.write(cbuf); this.logger.write(cbuf);
this.logger.put(this.fqcn, cbuf, 0, cbuf.length);
} }
@Override @Override
public void write(final char[] cbuf, final int off, final int len) throws IO Exception { public void write(final char[] cbuf, final int off, final int len) throws IO Exception {
this.out.write(cbuf, off, len); this.logger.write(cbuf, off, len);
this.logger.put(this.fqcn, cbuf, off, len);
} }
@Override @Override
public void write(final int c) throws IOException { public void write(final int c) throws IOException {
this.out.write(c); this.logger.write(c);
this.logger.put(this.fqcn, (char) c);
} }
@Override @Override
public void write(final String str) throws IOException { public void write(final String str) throws IOException {
this.out.write(str); this.logger.write(str);
this.logger.put(this.fqcn, str, 0, str.length());
} }
@Override @Override
public void write(final String str, final int off, final int len) throws IOE xception { public void write(final String str, final int off, final int len) throws IOE xception {
this.out.write(str, off, len); this.logger.write(str, off, len);
this.logger.put(this.fqcn, str, off, len);
} }
} }
 End of changes. 11 change blocks. 
18 lines changed or deleted 12 lines changed or added

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