You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/04 18:57:12 UTC
[5/5] git commit: Refactor LoggerStream constructors into builder
class.
Refactor LoggerStream constructors into builder class.
- Now all the relevant classes can be constructed from a single unified builder class: LoggerStreams.
- Removed a lot of constructors.
- All constructors are now protected to allow for extension.
- Updated tests to use builder.
- Some documentation updated.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3faed6d4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3faed6d4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3faed6d4
Branch: refs/heads/master
Commit: 3faed6d42a6b87e068b431df5fcdf4066cc59a1d
Parents: 7f3bcce
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 4 11:56:30 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:50 2014 -0500
----------------------------------------------------------------------
.../log4j/io/LoggerBufferedInputStream.java | 51 +---
.../logging/log4j/io/LoggerBufferedReader.java | 26 +-
.../log4j/io/LoggerFilterOutputStream.java | 25 +-
.../logging/log4j/io/LoggerFilterWriter.java | 14 +-
.../logging/log4j/io/LoggerInputStream.java | 23 +-
.../logging/log4j/io/LoggerOutputStream.java | 22 +-
.../logging/log4j/io/LoggerPrintStream.java | 79 +-----
.../logging/log4j/io/LoggerPrintWriter.java | 46 +---
.../apache/logging/log4j/io/LoggerReader.java | 17 +-
.../apache/logging/log4j/io/LoggerStreams.java | 267 +++++++++++--------
.../apache/logging/log4j/io/LoggerWriter.java | 12 +-
.../apache/logging/log4j/io/package-info.java | 20 ++
.../io/AbstractLoggerOutputStreamTest.java | 18 +-
.../log4j/io/AbstractLoggerWriterTest.java | 18 +-
...LoggerBufferedInputStreamCallerInfoTest.java | 12 +-
.../log4j/io/LoggerBufferedInputStreamTest.java | 6 +-
.../io/LoggerBufferedReaderCallerInfoTest.java | 10 +-
.../log4j/io/LoggerBufferedReaderTest.java | 13 +-
.../log4j/io/LoggerFilterOutputStreamTest.java | 5 +-
.../log4j/io/LoggerFilterWriterTest.java | 5 +-
.../io/LoggerInputStreamCallerInfoTest.java | 9 +-
.../logging/log4j/io/LoggerInputStreamTest.java | 13 +-
.../io/LoggerOutputStreamCallerInfoTest.java | 6 +-
.../log4j/io/LoggerOutputStreamTest.java | 4 +-
.../io/LoggerPrintStreamCallerInfoTest.java | 12 +-
.../logging/log4j/io/LoggerPrintStreamTest.java | 13 +-
.../io/LoggerPrintWriterCallerInfoTest.java | 7 +-
.../logging/log4j/io/LoggerPrintWriterTest.java | 11 +-
.../log4j/io/LoggerReaderCallerInfoTest.java | 7 +-
.../logging/log4j/io/LoggerReaderTest.java | 9 +-
.../logging/log4j/io/LoggerWriterTest.java | 4 +-
31 files changed, 358 insertions(+), 426 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
index 75dbb2f..0949f13 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
@@ -29,54 +29,17 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
public class LoggerBufferedInputStream extends BufferedInputStream {
private static final String FQCN = LoggerBufferedInputStream.class.getName();
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level) {
- this(in, charset, logger, FQCN, level, null);
+ protected LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
+ final String fqcn, final Level level, final Marker marker) {
+ super(new LoggerInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker));
}
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, charset, logger, FQCN, level, marker);
+ protected LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size,
+ final ExtendedLogger logger, final String fqcn, final Level level,
+ final Marker marker) {
+ super(new LoggerInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker), size);
}
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerInputStream(in, charset, logger, fqcn, level, marker));
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final Level level) {
- this(in, charset, size, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, charset, size, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerInputStream(in, charset, logger, fqcn, level, marker), size);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final Level level) {
- this(in, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- this(in, Charset.defaultCharset(), logger, fqcn, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final Level level) {
- this(in, size, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, size, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- this(in, Charset.defaultCharset(), size, logger, fqcn, level, marker);
- }
-
@Override
public void close() throws IOException {
super.close();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
index 756f41a..9788f18 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
@@ -29,28 +29,14 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
public class LoggerBufferedReader extends BufferedReader {
private static final String FQCN = LoggerBufferedReader.class.getName();
- public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final Level level) {
- this(reader, logger, FQCN, level, null);
+ protected LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final String fqcn,
+ final Level level, final Marker marker) {
+ super(new LoggerReader(reader, logger, fqcn == null ? FQCN : fqcn, level, marker));
}
- public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(reader, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerReader(reader, logger, FQCN, level, marker));
- }
-
- public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final Level level) {
- this(reader, size, logger, FQCN, level, null);
- }
-
- public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(reader, size, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerReader(reader, logger, FQCN, level, marker), size);
+ protected LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final String fqcn,
+ final Level level, final Marker marker) {
+ super(new LoggerReader(reader, logger, fqcn == null ? FQCN : fqcn, level, marker), size);
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
index d17544c..295c3e4 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
@@ -38,30 +38,11 @@ public class LoggerFilterOutputStream extends FilterOutputStream {
private final ByteStreamLogger logger;
private final String fqcn;
- public LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
- final Level level) {
- this(out, charset, logger, FQCN, level, null);
- }
-
- public LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
- final Level level, final Marker marker) {
- this(out, charset, logger, FQCN, level, marker);
- }
-
- public LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
- final String fqcn, final Level level, final Marker marker) {
+ protected LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
+ final String fqcn, final Level level, final Marker marker) {
super(out);
this.logger = new ByteStreamLogger(logger, level, marker, charset);
- this.fqcn = fqcn;
- }
-
- public LoggerFilterOutputStream(final OutputStream out, final ExtendedLogger logger, final Level level) {
- this(out, Charset.defaultCharset(), logger, FQCN, level, null);
- }
-
- public LoggerFilterOutputStream(final OutputStream out, final ExtendedLogger logger, final Level level,
- final Marker marker) {
- this(out, Charset.defaultCharset(), logger, FQCN, level, marker);
+ this.fqcn = fqcn == null ? FQCN : fqcn;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
index 5a9d8e0..c6b523d 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
@@ -35,19 +35,11 @@ public class LoggerFilterWriter extends FilterWriter {
private final CharStreamLogger logger;
private final String fqcn;
- public LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final Level level) {
- this(out, logger, FQCN, level, null);
- }
-
- public LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(out, logger, FQCN, level, marker);
- }
-
- public LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final String fqcn, final Level level,
- final Marker marker) {
+ protected LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final String fqcn, final Level level,
+ final Marker marker) {
super(out);
this.logger = new CharStreamLogger(logger, level, marker);
- this.fqcn = fqcn;
+ this.fqcn = fqcn == null ? FQCN : fqcn;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
index 445e366..ff76b7f 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
@@ -35,28 +35,11 @@ public class LoggerInputStream extends FilterInputStream {
private final String fqcn;
private final ByteStreamLogger logger;
- public LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level) {
- this(in, charset, logger, FQCN, level, null);
- }
-
- public LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level,
- final Marker marker) {
- this(in, charset, logger, FQCN, level, marker);
- }
-
- public LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
- final String fqcn, final Level level, final Marker marker) {
+ protected LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
+ final String fqcn, final Level level, final Marker marker) {
super(in);
this.logger = new ByteStreamLogger(logger, level, marker, charset);
- this.fqcn = fqcn;
- }
-
- public LoggerInputStream(final InputStream in, final ExtendedLogger logger, final Level level) {
- this(in, Charset.defaultCharset(), logger, FQCN, level, null);
- }
-
- public LoggerInputStream(final InputStream in, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, Charset.defaultCharset(), logger, FQCN, level, marker);
+ this.fqcn = fqcn == null ? FQCN : fqcn;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
index 0d1829b..af8b2fe 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
@@ -37,26 +37,10 @@ public class LoggerOutputStream extends OutputStream {
private final ByteStreamLogger logger;
private final String fqcn;
- public LoggerOutputStream(final ExtendedLogger logger, final Level level) {
- this(logger, level, null, Charset.defaultCharset(), FQCN);
- }
-
- public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Charset charset) {
- this(logger, level, null, charset, FQCN);
- }
-
- public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker) {
- this(logger, level, marker, Charset.defaultCharset(), FQCN);
- }
-
- public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset) {
- this(logger, level, marker, charset, FQCN);
- }
-
- public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker,
- final Charset charset, final String fqcn) {
+ protected LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker,
+ final Charset charset, final String fqcn) {
this.logger = new ByteStreamLogger(logger, level, marker, charset);
- this.fqcn = fqcn;
+ this.fqcn = fqcn == null ? FQCN : fqcn;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
index f5d51a5..d51b492 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
@@ -37,77 +37,22 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
public class LoggerPrintStream extends PrintStream {
private static final String FQCN = LoggerPrintStream.class.getName();
- public LoggerPrintStream(final ExtendedLogger logger, final boolean autoFlush, final Charset charset,
- final String fqcn, final Level level, final Marker marker) throws UnsupportedEncodingException {
- super(new LoggerOutputStream(logger, level, marker, charset, fqcn), autoFlush, charset.name());
+ protected LoggerPrintStream(final ExtendedLogger logger, final boolean autoFlush, final Charset charset,
+ final String fqcn, final Level level, final Marker marker)
+ throws UnsupportedEncodingException {
+ super(new LoggerOutputStream(logger, level, marker, ensureNonNull(charset), fqcn == null ? FQCN : fqcn),
+ autoFlush, ensureNonNull(charset).name());
}
- public LoggerPrintStream(final ExtendedLogger logger, final Level level) throws UnsupportedEncodingException {
- this(logger, false, Charset.defaultCharset(), FQCN, level, null);
+ protected LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
+ final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker)
+ throws UnsupportedEncodingException {
+ super(new LoggerFilterOutputStream(out, ensureNonNull(charset), logger, fqcn == null ? FQCN : fqcn, level,
+ marker), autoFlush, ensureNonNull(charset).name());
}
- public LoggerPrintStream(final ExtendedLogger logger, final Level level, final Charset charset)
- throws UnsupportedEncodingException {
- this(logger, false, charset, FQCN, level, null);
- }
-
- public LoggerPrintStream(final ExtendedLogger logger, final Level level, final Marker marker)
- throws UnsupportedEncodingException {
- this(logger, false, Charset.defaultCharset(), FQCN, level, marker);
- }
-
- public LoggerPrintStream(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset)
- throws UnsupportedEncodingException {
- this(logger, false, charset, FQCN, level, marker);
- }
-
- public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
- final ExtendedLogger logger, final Level level) throws UnsupportedEncodingException {
- this(out, autoFlush, charset, logger, FQCN, level, null);
- }
-
- public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
- final ExtendedLogger logger, final Level level, final Marker marker) throws UnsupportedEncodingException {
- this(out, autoFlush, charset, logger, FQCN, level, marker);
- }
-
- public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
- final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker)
- throws UnsupportedEncodingException {
- super(new LoggerFilterOutputStream(out, charset, logger, fqcn, level, marker), autoFlush, charset.name());
- }
-
- public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final ExtendedLogger logger,
- final Level level) {
- this(out, autoFlush, logger, FQCN, level, null);
- }
-
- public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final ExtendedLogger logger,
- final Level level, final Marker marker) {
- this(out, autoFlush, logger, FQCN, level, marker);
- }
-
- public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final ExtendedLogger logger,
- final String fqcn, final Level level, final Marker marker) {
- super(new LoggerFilterOutputStream(out, Charset.defaultCharset(), logger, fqcn, level, marker), autoFlush);
- }
-
- public LoggerPrintStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
- final Level level) throws UnsupportedEncodingException {
- this(out, false, charset, logger, FQCN, level, null);
- }
-
- public LoggerPrintStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
- final Level level, final Marker marker) throws UnsupportedEncodingException {
- this(out, false, charset, logger, FQCN, level, marker);
- }
-
- public LoggerPrintStream(final OutputStream out, final ExtendedLogger logger, final Level level) {
- this(out, false, logger, FQCN, level, null);
- }
-
- public LoggerPrintStream(final OutputStream out, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(out, false, logger, FQCN, level, marker);
+ private static Charset ensureNonNull(final Charset charset) {
+ return charset == null ? Charset.defaultCharset() : charset;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
index 500d255..6848463 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
@@ -31,7 +31,12 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
* <p>
* Integration with JDBC logging can be as simple as:
* </p>
- * <pre>DriverManager.setLogWriter(new LoggerPrintWriter((ExtendedLogger) LogManager.getLogger(), Level.DEBUG));
+ * <pre>
+ * Logger logger = LogManager.getLogger();
+ * PrintWriter pw = LoggerStreams.forLogger(logger).setLevel(Level.DEBUG).buildPrintWriter();
+ * DriverManager.setLogWriter(pw);
+ * DataSource ds = ...
+ * ds.setLogWriter(pw);
* </pre>
*/
// TODO
@@ -40,41 +45,14 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
public class LoggerPrintWriter extends PrintWriter {
private static final String FQCN = LoggerPrintWriter.class.getName();
- @SuppressWarnings("resource")
- public LoggerPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
- final Level level, final Marker marker) {
- super(new LoggerWriter(logger, fqcn, level, marker), autoFlush);
+ protected LoggerPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
+ final Level level, final Marker marker) {
+ super(new LoggerWriter(logger, fqcn == null ? FQCN : fqcn, level, marker), autoFlush);
}
- public LoggerPrintWriter(final ExtendedLogger logger, final Level level) {
- this(logger, false, FQCN, level, null);
- }
-
- public LoggerPrintWriter(final ExtendedLogger logger, final Level level, final Marker marker) {
- this(logger, false, FQCN, level, marker);
- }
-
- public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger, final Level level) {
- this(writer, autoFlush, logger, FQCN, level, null);
- }
-
- public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger, final Level level,
- final Marker marker) {
- this(writer, autoFlush, logger, FQCN, level, marker);
- }
-
- @SuppressWarnings("resource")
- public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
- final String fqcn, final Level level, final Marker marker) {
- super(new LoggerFilterWriter(writer, logger, fqcn, level, marker), autoFlush);
- }
-
- public LoggerPrintWriter(final Writer writer, final ExtendedLogger logger, final Level level) {
- this(writer, false, logger, FQCN, level, null);
- }
-
- public LoggerPrintWriter(final Writer writer, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(writer, false, logger, FQCN, level, marker);
+ protected LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
+ final String fqcn, final Level level, final Marker marker) {
+ super(new LoggerFilterWriter(writer, logger, fqcn == null ? FQCN : fqcn, level, marker), autoFlush);
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
index 48427f8..652cb01 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
@@ -27,8 +27,7 @@ import org.apache.logging.log4j.Marker;
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
- * that follows the {@link java.io.Writer} methods in spirit, but doesn't require output to any external writer.
+ * Logs each line read to a pre-defined level. Can also be configured with a Marker.
*/
public class LoggerReader extends FilterReader {
private static final String FQCN = LoggerReader.class.getName();
@@ -36,19 +35,11 @@ public class LoggerReader extends FilterReader {
private final CharStreamLogger logger;
private final String fqcn;
- public LoggerReader(final Reader reader, final ExtendedLogger logger, final Level level) {
- this(reader, logger, FQCN, level, null);
- }
-
- public LoggerReader(final Reader reader, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(reader, logger, FQCN, level, marker);
- }
-
- public LoggerReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level,
- final Marker marker) {
+ protected LoggerReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level,
+ final Marker marker) {
super(reader);
this.logger = new CharStreamLogger(logger, level, marker);
- this.fqcn = fqcn;
+ this.fqcn = fqcn == null ? FQCN : fqcn;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
index 6378d19..20a2926 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
@@ -2,7 +2,7 @@
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
@@ -11,160 +11,213 @@
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
*/
-
package org.apache.logging.log4j.io;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.Charset;
import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LoggingException;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.spi.ExtendedLogger;
+/**
+ * Builder class to wrap {@link org.apache.logging.log4j.Logger Loggers} into Java IO compatible classes.
+ *
+ * @since 2.1
+ */
public class LoggerStreams {
+ private final ExtendedLogger logger;
+ private Level level;
+ private Marker marker;
+ private String fqcn;
+ private boolean autoFlush;
+ private boolean buffered;
+ private int bufferSize;
+ private Charset charset;
+ private Reader reader;
+ private Writer writer;
+ private InputStream inputStream;
+ private OutputStream outputStream;
+
+ /**
+ * Creates a new builder for a given {@link Logger}. The Logger instance must implement {@link ExtendedLogger} or
+ * an exception will be thrown.
+ *
+ * @param logger the Logger to wrap into a LoggerStream
+ * @return a new LoggerStream builder
+ * @throws IncompatibleLoggerException if {@code logger} does not implement {@link ExtendedLogger} or if
+ * {@code logger} is {@code null}
+ */
+ public static LoggerStreams forLogger(final Logger logger) {
+ return new LoggerStreams(logger);
+ }
- public static class BufferedBuilder {
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
- private final int size;
-
- BufferedBuilder(final ExtendedLogger logger, final Level level, final Marker marker, final int size) {
- this.logger = logger;
- this.level = level;
- this.marker = marker;
- this.size = size;
- }
-
- public LoggerBufferedInputStream create(final InputStream in) {
- if (this.size > 0) {
- return new LoggerBufferedInputStream(in, this.size, this.logger, this.level, this.marker);
- }
- return new LoggerBufferedInputStream(in, this.logger, this.level, this.marker);
- }
-
- public LoggerBufferedInputStream create(final InputStream in, final Charset charset) {
- if (this.size > 0) {
- return new LoggerBufferedInputStream(in, charset, this.size, this.logger, this.level, this.marker);
- }
- return new LoggerBufferedInputStream(in, charset, this.logger, this.level, this.marker);
- }
+ public static LoggerStreams forLogger(final String loggerName) {
+ return new LoggerStreams(LogManager.getLogger(loggerName));
+ }
- public LoggerBufferedReader create(final Reader reader) {
- if (this.size > 0) {
- return new LoggerBufferedReader(reader, this.size, this.logger, this.level, this.marker);
- }
- return new LoggerBufferedReader(reader, this.logger, this.level, this.marker);
- }
+ public static LoggerStreams forLogger(final Class<?> clazz) {
+ return new LoggerStreams(LogManager.getLogger(clazz));
+ }
- public BufferedBuilder marker(final Marker marker) {
- return new BufferedBuilder(this.logger, this.level, marker, this.size);
- }
+ // TODO: arg-less factory (blocked by LOG4J2-809)
- public BufferedBuilder size(final int size) {
- return new BufferedBuilder(this.logger, this.level, this.marker, size);
+ private LoggerStreams(final Logger logger) {
+ if (!(logger instanceof ExtendedLogger)) {
+ throw new IncompatibleLoggerException(logger);
}
+ this.logger = (ExtendedLogger) logger;
}
- public static class Builder {
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
+ public LoggerStreams setLevel(final Level level) {
+ this.level = level;
+ return this;
+ }
- Builder(final ExtendedLogger logger, final Level level, final Marker marker) {
- this.logger = logger;
- this.level = level;
- this.marker = marker;
- }
+ public LoggerStreams setMarker(final Marker marker) {
+ this.marker = marker;
+ return this;
+ }
- public BufferedBuilder buffered() {
- return new BufferedBuilder(this.logger, this.level, this.marker, 0);
- }
+ public LoggerStreams setWrapperClassName(final String fqcn) {
+ this.fqcn = fqcn;
+ return this;
+ }
- public LoggerFilterWriter create(final Writer writer) {
- return new LoggerFilterWriter(writer, this.logger, this.level, this.marker);
- }
+ public LoggerStreams setAutoFlush(final boolean autoFlush) {
+ this.autoFlush = autoFlush;
+ return this;
+ }
- public Builder marker(final Marker marker) {
- return new Builder(this.logger, this.level, marker);
- }
+ /**
+ * Enables or disables using a buffered variant of the desired IO class. If this is set to {@code true}, then the
+ * instances returned by {@link #buildReader()} and {@link #buildInputStream()} can be safely cast (if necessary)
+ * to {@link java.io.BufferedReader} and {@link java.io.BufferedInputStream} respectively. This option does not
+ * have any effect on the other built variants.
+ *
+ * @param buffered indicates whether or not an input LoggerStream should be buffered
+ * @return {@code this}
+ */
+ public LoggerStreams setBuffered(final boolean buffered) {
+ this.buffered = buffered;
+ return this;
+ }
- public PrintingBuilder printing() {
- return new PrintingBuilder(this.logger, this.level, this.marker, false);
- }
+ public LoggerStreams setBufferSize(final int bufferSize) {
+ this.bufferSize = bufferSize;
+ return this;
}
- public static class PrintingBuilder {
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
- private final boolean autoFlush;
+ public LoggerStreams setCharset(final Charset charset) {
+ this.charset = charset;
+ return this;
+ }
- PrintingBuilder(final ExtendedLogger logger, final Level level, final Marker marker, final boolean autoFlush) {
- this.logger = logger;
- this.level = level;
- this.marker = marker;
- this.autoFlush = autoFlush;
- }
+ public LoggerStreams filter(final Reader reader) {
+ this.reader = reader;
+ return this;
+ }
- public PrintingBuilder autoFlush() {
- return autoFlush(true);
- }
+ public LoggerStreams filter(final Writer writer) {
+ this.writer = writer;
+ return this;
+ }
- public PrintingBuilder autoFlush(final boolean autoFlush) {
- return new PrintingBuilder(this.logger, this.level, this.marker, autoFlush);
- }
+ public LoggerStreams filter(final InputStream inputStream) {
+ this.inputStream = inputStream;
+ return this;
+ }
- public LoggerPrintStream create(final OutputStream out) {
- return new LoggerPrintStream(out, this.autoFlush, this.logger, this.level, this.marker);
- }
+ public LoggerStreams filter(final OutputStream outputStream) {
+ this.outputStream = outputStream;
+ return this;
+ }
- public LoggerPrintStream create(final OutputStream out, final Charset charset) {
- try {
- return new LoggerPrintStream(out, this.autoFlush, charset, this.logger, this.level, this.marker);
- } catch (final UnsupportedEncodingException e) {
- // Should never occur because the constructor must throw this
- throw new IllegalArgumentException("Invalid charset", e);
+ public Reader buildReader() {
+ final Reader r = requireNonNull(this.reader, "reader");
+ if (this.buffered) {
+ if (this.bufferSize > 0) {
+ return new LoggerBufferedReader(r, this.bufferSize, this.logger, this.fqcn, this.level, this.marker);
+ } else {
+ return new LoggerBufferedReader(r, this.logger, this.fqcn, this.level, this.marker);
}
+ } else {
+ return new LoggerReader(requireNonNull(this.reader, "reader"), this.logger, this.fqcn, this.level,
+ this.marker);
}
+ }
- public LoggerPrintWriter create(final Writer writer) {
- return new LoggerPrintWriter(writer, this.autoFlush, this.logger, this.level, this.marker);
- }
-
- public PrintingBuilder marker(final Marker marker) {
- return new PrintingBuilder(this.logger, this.level, marker, this.autoFlush);
+ public Writer buildWriter() {
+ if (this.writer == null) {
+ return new LoggerWriter(this.logger, this.fqcn, this.level, this.marker);
+ } else {
+ return new LoggerFilterWriter(this.writer, this.logger, this.fqcn, this.level, this.marker);
}
}
- public static Builder debug(final ExtendedLogger logger) {
- return new Builder(logger, Level.DEBUG, null);
+ public PrintWriter buildPrintWriter() {
+ if (this.writer == null) {
+ return new LoggerPrintWriter(this.logger, this.autoFlush, this.fqcn, this.level, this.marker);
+ } else {
+ return new LoggerPrintWriter(this.writer, this.autoFlush, this.logger, this.fqcn, this.level, this.marker);
+ }
}
- public static Builder error(final ExtendedLogger logger) {
- return new Builder(logger, Level.ERROR, null);
+ public InputStream buildInputStream() {
+ final InputStream i = requireNonNull(this.inputStream, "inputStream");
+ if (this.buffered) {
+ if (this.bufferSize > 0) {
+ return new LoggerBufferedInputStream(i, this.charset, this.bufferSize, this.logger, this.fqcn,
+ this.level, this.marker);
+ } else {
+ return new LoggerBufferedInputStream(i, this.charset, this.logger, this.fqcn, this.level, this.marker);
+ }
+ }
+ return new LoggerInputStream(requireNonNull(this.inputStream, "inputStream"), this.charset, this.logger,
+ this.fqcn, this.level, this.marker);
}
- public static Builder fatal(final ExtendedLogger logger) {
- return new Builder(logger, Level.FATAL, null);
+ public OutputStream buildOutputStream() {
+ if (this.outputStream == null) {
+ return new LoggerOutputStream(this.logger, this.level, this.marker, this.charset, this.fqcn);
+ } else {
+ return new LoggerFilterOutputStream(this.outputStream, this.charset, this.logger, this.fqcn, this.level,
+ this.marker);
+ }
}
- public static Builder info(final ExtendedLogger logger) {
- return new Builder(logger, Level.INFO, null);
+ public PrintStream buildPrintStream() {
+ try {
+ if (this.outputStream == null) {
+ return new LoggerPrintStream(this.logger, this.autoFlush, this.charset, this.fqcn, this.level,
+ this.marker);
+ } else {
+ return new LoggerPrintStream(this.outputStream, this.autoFlush, this.charset, this.logger, this.fqcn,
+ this.level, this.marker);
+ }
+ } catch (final UnsupportedEncodingException e) {
+ // this exception shouldn't really happen since we use Charset and not String
+ throw new LoggingException(e);
+ }
}
- public static Builder trace(final ExtendedLogger logger) {
- return new Builder(logger, Level.TRACE, null);
+ private static <T> T requireNonNull(final T obj, final String name) {
+ if (obj == null) {
+ throw new IllegalStateException("The property " + name + " was not set");
+ }
+ return obj;
}
- public static Builder warn(final ExtendedLogger logger) {
- return new Builder(logger, Level.WARN, null);
- }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
index 70310ad..b49cedf 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
@@ -34,17 +34,9 @@ public class LoggerWriter extends Writer {
private final CharStreamLogger logger;
private final String fqcn;
- public LoggerWriter(final ExtendedLogger logger, final Level level) {
- this(logger, FQCN, level, null);
- }
-
- public LoggerWriter(final ExtendedLogger logger, final Level level, final Marker marker) {
- this(logger, FQCN, level, marker);
- }
-
- public LoggerWriter(final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
+ protected LoggerWriter(final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
this.logger = new CharStreamLogger(logger, level, marker);
- this.fqcn = fqcn;
+ this.fqcn = fqcn == null ? FQCN : fqcn;
}
@Override
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java
new file mode 100644
index 0000000..ea0d6ff
--- /dev/null
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+/**
+ * TODO: introduction to LoggerStreams
+ */
+package org.apache.logging.log4j.io;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
index a41b6dd..d0f82e2 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
@@ -16,10 +16,6 @@
*/
package org.apache.logging.log4j.io;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -28,6 +24,10 @@ import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.*;
+
public abstract class AbstractLoggerOutputStreamTest extends AbstractStreamTest {
protected OutputStream out;
protected ByteArrayOutputStream wrapped;
@@ -69,9 +69,13 @@ public abstract class AbstractLoggerOutputStreamTest extends AbstractStreamTest
out.close();
replay(out);
- final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
- los.flush();
- los.close();
+ final OutputStream filteredOut =
+ LoggerStreams.forLogger(getExtendedLogger())
+ .filter(out)
+ .setLevel(LEVEL)
+ .buildOutputStream();
+ filteredOut.flush();
+ filteredOut.close();
verify(out);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
index 6fe81bc..9cc0fbb 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
@@ -16,10 +16,6 @@
*/
package org.apache.logging.log4j.io;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
@@ -29,6 +25,10 @@ import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.*;
+
public abstract class AbstractLoggerWriterTest extends AbstractStreamTest {
protected StringWriter wrapped;
protected Writer writer;
@@ -70,9 +70,13 @@ public abstract class AbstractLoggerWriterTest extends AbstractStreamTest {
out.close();
replay(out);
- final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
- los.flush();
- los.close();
+ final OutputStream filteredOut =
+ LoggerStreams.forLogger(getExtendedLogger())
+ .filter(out)
+ .setLevel(LEVEL)
+ .buildOutputStream();
+ filteredOut.flush();
+ filteredOut.close();
verify(out);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
index 860f3b8..2822c89 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.io;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -24,8 +25,8 @@ import org.junit.Test;
public class LoggerBufferedInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- private LoggerBufferedInputStream logIn;
-
+ private BufferedInputStream logIn;
+
@Test
public void close() throws Exception {
this.logIn.read();
@@ -61,6 +62,11 @@ public class LoggerBufferedInputStreamCallerInfoTest extends LoggerStreamsCaller
@Before
public void setupStreams() {
final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
- this.logIn = new LoggerBufferedInputStream(srcInputStream, getLogger(), LEVEL);
+ this.logIn = (BufferedInputStream)
+ LoggerStreams.forLogger(getLogger())
+ .filter(srcInputStream)
+ .setLevel(LEVEL)
+ .setBuffered(true)
+ .buildInputStream();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
index d2ba6b0..dc1add2 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
@@ -24,6 +24,10 @@ public class LoggerBufferedInputStreamTest extends LoggerInputStreamTest {
@Override
protected InputStream createInputStream() {
- return new LoggerBufferedInputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(Level.ERROR)
+ .setBuffered(true)
+ .buildInputStream();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
index 2d9ff12..bd07f6d 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.io;
+import java.io.BufferedReader;
import java.io.Reader;
import java.io.StringReader;
import java.nio.CharBuffer;
@@ -26,7 +27,7 @@ import org.junit.Test;
public class LoggerBufferedReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- LoggerBufferedReader logReader;
+ BufferedReader logReader;
@Test
public void close() throws Exception {
@@ -79,6 +80,11 @@ public class LoggerBufferedReaderCallerInfoTest extends LoggerStreamsCallerInfoT
@Before
public void setupReader() {
final Reader srcReader = new StringReader("a\nb\nc\nd");
- this.logReader = new LoggerBufferedReader(srcReader, getLogger(), Level.WARN);
+ this.logReader = (BufferedReader)
+ LoggerStreams.forLogger(getLogger())
+ .filter(srcReader)
+ .setLevel(Level.WARN)
+ .setBuffered(true)
+ .buildReader();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
index 68e1811..88e5a03 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
@@ -16,19 +16,24 @@
*/
package org.apache.logging.log4j.io;
-import static org.junit.Assert.assertEquals;
-
import java.io.BufferedReader;
import java.io.Reader;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LoggerBufferedReaderTest extends LoggerReaderTest {
private BufferedReader bufferedReader;
-
+
@Override
protected Reader createReader() {
- return this.bufferedReader = new LoggerBufferedReader(this.wrapped, getExtendedLogger(), LEVEL);
+ return this.bufferedReader = (BufferedReader)
+ LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(LEVEL)
+ .setBuffered(true)
+ .buildReader();
}
@Test
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
index 60e48c5..95f637b 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
@@ -30,7 +30,10 @@ public class LoggerFilterOutputStreamTest extends AbstractLoggerOutputStreamTest
@Override
protected OutputStream createOutputStreamWrapper() {
- return new LoggerFilterOutputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(Level.ERROR)
+ .buildOutputStream();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
index a58a51e..dbde900 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
@@ -12,7 +12,10 @@ public class LoggerFilterWriterTest extends AbstractLoggerWriterTest {
@Override
protected Writer createWriterWrapper() {
- return new LoggerFilterWriter(this.wrapped, getExtendedLogger(), LEVEL);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(LEVEL)
+ .buildWriter();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
index bd812aa..690352e 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
@@ -25,8 +25,8 @@ import org.junit.Test;
public class LoggerInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- private LoggerInputStream logIn;
-
+ private InputStream logIn;
+
@Test
public void read() throws Exception {
this.logIn.read();
@@ -49,6 +49,9 @@ public class LoggerInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTest
@Before
public void setupStreams() {
final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
- this.logIn = new LoggerInputStream(srcInputStream, getLogger(), Level.WARN);
+ this.logIn = LoggerStreams.forLogger(getLogger())
+ .filter(srcInputStream)
+ .setLevel(Level.WARN)
+ .buildInputStream();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
index cd727a6..f0c6d48 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.logging.log4j.io;
-import static org.junit.Assert.assertEquals;
-
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -27,13 +25,18 @@ import java.io.InputStream;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LoggerInputStreamTest extends AbstractStreamTest {
protected ByteArrayInputStream wrapped;
protected ByteArrayOutputStream read;
protected InputStream in;
protected InputStream createInputStream() {
- return new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(LEVEL)
+ .buildInputStream();
}
@Before
@@ -55,7 +58,7 @@ public class LoggerInputStreamTest extends AbstractStreamTest {
@Test
public void testClose_NoRemainingData() throws IOException {
this.wrapped = new ByteArrayInputStream((FIRST + '\n').getBytes());
- this.in = new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+ this.in = createInputStream();
final byte[] bytes = new byte[1024];
this.in.read(bytes);
@@ -116,7 +119,7 @@ public class LoggerInputStreamTest extends AbstractStreamTest {
@Test
public void testRead_MultipleLines() throws IOException {
this.wrapped = new ByteArrayInputStream((FIRST + "\n" + LAST + '\n').getBytes());
- this.in = new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+ this.in = createInputStream();
final byte[] bytes = new byte[1024];
final int len = this.in.read(bytes);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
index c013fc6..cee3952 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
@@ -16,17 +16,19 @@
*/
package org.apache.logging.log4j.io;
+import java.io.OutputStream;
+
import org.apache.logging.log4j.Level;
import org.junit.Before;
import org.junit.Test;
public class LoggerOutputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- private LoggerOutputStream logOut;
+ private OutputStream logOut;
@Before
public void setupStreams() {
- this.logOut = new LoggerOutputStream(getExtendedLogger(), Level.WARN);
+ this.logOut = LoggerStreams.forLogger(getExtendedLogger()).setLevel(Level.WARN).buildOutputStream();
}
@Test
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
index 1631336..42f752c 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
@@ -30,7 +30,9 @@ public class LoggerOutputStreamTest extends AbstractLoggerOutputStreamTest {
@Override
protected OutputStream createOutputStreamWrapper() {
- return new LoggerOutputStream(getExtendedLogger(), Level.ERROR);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .setLevel(Level.ERROR)
+ .buildOutputStream();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
index 2c533c3..84197e8 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.logging.log4j.io;
-import java.io.UnsupportedEncodingException;
+import java.io.PrintStream;
import java.util.Locale;
import org.apache.logging.log4j.Level;
@@ -25,8 +25,8 @@ import org.junit.Test;
public class LoggerPrintStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- private LoggerPrintStream logOut;
-
+ private PrintStream logOut;
+
@Test
public void close() throws Exception {
this.logOut.print("a\nb");
@@ -120,8 +120,10 @@ public class LoggerPrintStreamCallerInfoTest extends LoggerStreamsCallerInfoTest
}
@Before
- public void setupStreams() throws UnsupportedEncodingException {
- this.logOut = new LoggerPrintStream(getLogger(), Level.WARN);
+ public void setupStreams() {
+ this.logOut = LoggerStreams.forLogger(getLogger())
+ .setLevel(Level.WARN)
+ .buildPrintStream();
}
@Test
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
index 38dd793..37cea4e 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
@@ -16,16 +16,16 @@
*/
package org.apache.logging.log4j.io;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
+import java.io.PrintStream;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LoggerPrintStreamTest extends AbstractLoggerOutputStreamTest {
- private LoggerPrintStream print;
+ private PrintStream print;
@Override
protected ByteArrayOutputStream createOutputStream() {
@@ -34,7 +34,10 @@ public class LoggerPrintStreamTest extends AbstractLoggerOutputStreamTest {
@Override
protected OutputStream createOutputStreamWrapper() {
- return this.print = new LoggerPrintStream(this.wrapped, getExtendedLogger(), LEVEL);
+ return this.print = LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(LEVEL)
+ .buildPrintStream();
}
@Test
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
index 7502040..416b44d 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.io;
+import java.io.PrintWriter;
import java.util.Locale;
import org.apache.logging.log4j.Level;
@@ -24,7 +25,7 @@ import org.junit.Test;
public class LoggerPrintWriterCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- private LoggerPrintWriter logOut;
+ private PrintWriter logOut;
@Test
public void close() throws Exception {
@@ -120,7 +121,9 @@ public class LoggerPrintWriterCallerInfoTest extends LoggerStreamsCallerInfoTest
@Before
public void setupStreams() {
- this.logOut = new LoggerPrintWriter(getLogger(), Level.WARN);
+ this.logOut = LoggerStreams.forLogger(getLogger())
+ .setLevel(Level.WARN)
+ .buildPrintWriter();
}
@Test
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
index 7b13086..3559c75 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
@@ -16,15 +16,14 @@
*/
package org.apache.logging.log4j.io;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LoggerPrintWriterTest extends AbstractLoggerWriterTest {
private PrintWriter print;
@@ -35,7 +34,11 @@ public class LoggerPrintWriterTest extends AbstractLoggerWriterTest {
@Override
protected Writer createWriterWrapper() {
- this.print = new LoggerPrintWriter(this.wrapped, getExtendedLogger(), LEVEL);
+ this.print =
+ LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(LEVEL)
+ .buildPrintWriter();
return this.print;
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
index 5e114e3..f084234 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
public class LoggerReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
- LoggerReader logReader;
+ Reader logReader;
@Test
public void read() throws Exception {
@@ -52,6 +52,9 @@ public class LoggerReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
@Before
public void setupReader() {
final Reader srcReader = new StringReader("a\nb\nc\nd\ne");
- this.logReader = new LoggerReader(srcReader, getLogger(), LEVEL);
+ this.logReader = LoggerStreams.forLogger(getLogger())
+ .filter(srcReader)
+ .setLevel(LEVEL)
+ .buildReader();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
index 4f89d7b..10d715f 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.logging.log4j.io;
-import static org.junit.Assert.assertEquals;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
@@ -28,13 +26,18 @@ import java.nio.CharBuffer;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LoggerReaderTest extends AbstractStreamTest {
protected StringReader wrapped;
protected StringWriter read;
protected Reader reader;
protected Reader createReader() {
- return new LoggerReader(this.wrapped, getExtendedLogger(), LEVEL);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .filter(this.wrapped)
+ .setLevel(LEVEL)
+ .buildReader();
}
@Before
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
index 3d261be..0a302aa 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
@@ -28,7 +28,9 @@ public class LoggerWriterTest extends AbstractLoggerWriterTest {
@Override
protected Writer createWriterWrapper() {
- return new LoggerWriter(getExtendedLogger(), LEVEL);
+ return LoggerStreams.forLogger(getExtendedLogger())
+ .setLevel(LEVEL)
+ .buildWriter();
}
}