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/03 07:23:54 UTC
[2/6] Rename log4j-streams to log4j-iostreams.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterOutputStream.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterOutputStream.java
deleted file mode 100644
index 96ab4e1..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterOutputStream.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.streams.util.ByteStreamLogger;
-
-/**
- * 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.
- * This class should <em>not</em> be used as a stream for an underlying logger unless it's being used as a bridge.
- * Otherwise, infinite loops may occur!
- */
-public class LoggerFilterOutputStream extends FilterOutputStream {
- private static final String FQCN = LoggerFilterOutputStream.class.getName();
-
- 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) {
- 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);
- }
-
- @Override
- public void close() throws IOException {
- this.out.close();
- this.logger.close(this.fqcn);
- }
-
- @Override
- public void flush() throws IOException {
- this.out.flush();
- }
-
- @Override
- public String toString() {
- return LoggerFilterOutputStream.class.getSimpleName() + "{stream=" + this.out + '}';
- }
-
- @Override
- public void write(final byte[] b) throws IOException {
- this.out.write(b);
- this.logger.put(this.fqcn, b, 0, b.length);
- }
-
- @Override
- public void write(final byte[] b, final int off, final int len) throws IOException {
- this.out.write(b, off, len);
- this.logger.put(this.fqcn, b, off, len);
- }
-
- @Override
- public void write(final int b) throws IOException {
- this.out.write(b);
- this.logger.put(this.fqcn, (byte) (b & 0xFF));
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterWriter.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterWriter.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterWriter.java
deleted file mode 100644
index 2659c04..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterWriter.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.FilterWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.streams.util.CharStreamLogger;
-
-/**
- * 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 out.
- */
-public class LoggerFilterWriter extends FilterWriter {
- private static final String FQCN = LoggerFilterWriter.class.getName();
-
- 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) {
- super(out);
- this.logger = new CharStreamLogger(logger, level, marker);
- this.fqcn = fqcn;
- }
-
- @Override
- public void close() throws IOException {
- this.out.close();
- this.logger.close(this.fqcn);
- }
-
- @Override
- public void flush() throws IOException {
- this.out.flush();
- }
-
- @Override
- public String toString() {
- return LoggerFilterWriter.class.getSimpleName() + "{writer=" + this.out + '}';
- }
-
- @Override
- public void write(final char[] cbuf) throws IOException {
- this.out.write(cbuf);
- this.logger.put(this.fqcn, cbuf, 0, cbuf.length);
- }
-
- @Override
- public void write(final char[] cbuf, final int off, final int len) throws IOException {
- this.out.write(cbuf, off, len);
- this.logger.put(this.fqcn, cbuf, off, len);
- }
-
- @Override
- public void write(final int c) throws IOException {
- this.out.write(c);
- this.logger.put(this.fqcn, (char) c);
- }
-
- @Override
- public void write(final String str) throws IOException {
- this.out.write(str);
- this.logger.put(this.fqcn, str, 0, str.length());
- }
-
- @Override
- public void write(final String str, final int off, final int len) throws IOException {
- this.out.write(str, off, len);
- this.logger.put(this.fqcn, str, off, len);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java
deleted file mode 100644
index 64eb202..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.streams.util.ByteStreamLogger;
-
-/**
- * Logs each line read to a pre-defined level. Can also be configured with a Marker.
- */
-public class LoggerInputStream extends FilterInputStream {
- private static final String FQCN = LoggerInputStream.class.getName();
-
- 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) {
- 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);
- }
-
- @Override
- public void close() throws IOException {
- this.logger.close(this.fqcn);
- super.close();
- }
-
- @Override
- public int read() throws IOException {
- final int b = super.read();
- this.logger.put(this.fqcn, b);
- return b;
- }
-
- @Override
- public int read(final byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- @Override
- public int read(final byte[] b, final int off, final int len) throws IOException {
- final int bytesRead = super.read(b, off, len);
- this.logger.put(this.fqcn, b, off, bytesRead);
- return bytesRead;
- }
-
- @Override
- public String toString() {
- return LoggerInputStream.class.getSimpleName() + "{stream=" + this.in + '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java
deleted file mode 100644
index 836a20b..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.streams.util.ByteStreamLogger;
-
-/**
- * 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.
- * This class should <em>not</em> be used as a stream for an underlying logger unless it's being used as a bridge.
- * Otherwise, infinite loops may occur!
- */
-public class LoggerOutputStream extends OutputStream {
- private static final String FQCN = LoggerOutputStream.class.getName();
-
- 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) {
- this.logger = new ByteStreamLogger(logger, level, marker, charset);
- this.fqcn = fqcn;
- }
-
- @Override
- public void close() throws IOException {
- this.logger.close(this.fqcn);
- }
-
- @Override
- public void flush() throws IOException {
- // do nothing
- }
-
- @Override
- public void write(final byte[] b) throws IOException {
- this.logger.put(this.fqcn, b, 0, b.length);
- }
-
- @Override
- public void write(final byte[] b, final int off, final int len) throws IOException {
- this.logger.put(this.fqcn, b, off, len);
- }
-
- @Override
- public void write(final int b) throws IOException {
- this.logger.put(this.fqcn, (byte) (b & 0xFF));
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java
deleted file mode 100644
index 2deefdb..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.util.Locale;
-
-import org.apache.logging.log4j.Level;
-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.PrintStream} 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 unless it's being used as a bridge.
- * Otherwise, infinite loops may occur!
- */
-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());
- }
-
- public LoggerPrintStream(final ExtendedLogger logger, final Level level) throws UnsupportedEncodingException {
- this(logger, false, Charset.defaultCharset(), FQCN, level, null);
- }
-
- 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);
- }
-
- @Override
- public LoggerPrintStream append(final char c) {
- super.append(c);
- return this;
- }
-
- @Override
- public LoggerPrintStream append(final CharSequence csq) {
- super.append(csq);
- return this;
- }
-
- @Override
- public LoggerPrintStream append(final CharSequence csq, final int start, final int end) {
- super.append(csq, start, end);
- return this;
- }
-
- @Override
- public boolean checkError() {
- return super.checkError();
- }
-
- @Override
- public void close() {
- super.close();
- }
-
- @Override
- public void flush() {
- super.flush();
- }
-
- @Override
- public LoggerPrintStream format(final Locale l, final String format, final Object... args) {
- super.format(l, format, args);
- return this;
- }
-
- @Override
- public LoggerPrintStream format(final String format, final Object... args) {
- super.format(format, args);
- return this;
- }
-
- @Override
- public void print(final boolean b) {
- super.print(b);
- }
-
- @Override
- public void print(final char c) {
- super.print(c);
- }
-
- @Override
- public void print(final char[] s) {
- super.print(s);
- }
-
- @Override
- public void print(final double d) {
- super.print(d);
- }
-
- @Override
- public void print(final float f) {
- super.print(f);
- }
-
- @Override
- public void print(final int i) {
- super.print(i);
- }
-
- @Override
- public void print(final long l) {
- super.print(l);
- }
-
- @Override
- public void print(final Object obj) {
- super.print(obj);
- }
-
- @Override
- public void print(final String s) {
- super.print(s);
- }
-
- @Override
- public LoggerPrintStream printf(final Locale l, final String format, final Object... args) {
- super.printf(l, format, args);
- return this;
- }
-
- @Override
- public LoggerPrintStream printf(final String format, final Object... args) {
- super.printf(format, args);
- return this;
- }
-
- @Override
- public void println() {
- super.println();
- }
-
- @Override
- public void println(final boolean x) {
- super.println(x);
- }
-
- @Override
- public void println(final char x) {
- super.println(x);
- }
-
- @Override
- public void println(final char[] x) {
- super.println(x);
- }
-
- @Override
- public void println(final double x) {
- super.println(x);
- }
-
- @Override
- public void println(final float x) {
- super.println(x);
- }
-
- @Override
- public void println(final int x) {
- super.println(x);
- }
-
- @Override
- public void println(final long x) {
- super.println(x);
- }
-
- @Override
- public void println(final Object x) {
- super.println(x);
- }
-
- @Override
- public void println(final String x) {
- super.println(x);
- }
-
- @Override
- public String toString() {
- return LoggerPrintStream.class.getSimpleName() + "{stream=" + this.out + '}';
- }
-
- @Override
- public void write(final byte[] b) throws IOException {
- super.write(b);
- }
-
- @Override
- public void write(final byte[] b, final int off, final int len) {
- super.write(b, off, len);
- }
-
- @Override
- public void write(final int b) {
- super.write(b);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java
deleted file mode 100644
index e5cdf98..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.Locale;
-
-import org.apache.logging.log4j.Level;
-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.PrintWriter} methods in spirit, but doesn't require output to any external writer.
- * <p>
- * Integration with JDBC logging can be as simple as:
- * </p>
- * <pre>DriverManager.setLogWriter(new LoggerPrintWriter((ExtendedLogger) LogManager.getLogger(), Level.DEBUG));
- * </pre>
- */
-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);
- }
-
- 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);
- }
-
- @Override
- public LoggerPrintWriter append(final char c) {
- super.append(c);
- return this;
- }
-
- @Override
- public LoggerPrintWriter append(final CharSequence csq) {
- super.append(csq);
- return this;
- }
-
- @Override
- public LoggerPrintWriter append(final CharSequence csq, final int start, final int end) {
- super.append(csq, start, end);
- return this;
- }
-
- @Override
- public boolean checkError() {
- return super.checkError();
- }
-
- @Override
- public void close() {
- super.close();
- }
-
- @Override
- public void flush() {
- super.flush();
- }
-
- @Override
- public LoggerPrintWriter format(final Locale l, final String format, final Object... args) {
- super.format(l, format, args);
- return this;
- }
-
- @Override
- public LoggerPrintWriter format(final String format, final Object... args) {
- super.format(format, args);
- return this;
- }
-
- @Override
- public void print(final boolean b) {
- super.print(b);
- }
-
- @Override
- public void print(final char c) {
- super.print(c);
- }
-
- @Override
- public void print(final char[] s) {
- super.print(s);
- }
-
- @Override
- public void print(final double d) {
- super.print(d);
- }
-
- @Override
- public void print(final float f) {
- super.print(f);
- }
-
- @Override
- public void print(final int i) {
- super.print(i);
- }
-
- @Override
- public void print(final long l) {
- super.print(l);
- }
-
- @Override
- public void print(final Object obj) {
- super.print(obj);
- }
-
- @Override
- public void print(final String s) {
- super.print(s);
- }
-
- @Override
- public LoggerPrintWriter printf(final Locale l, final String format, final Object... args) {
- super.printf(l, format, args);
- return this;
- }
-
- @Override
- public LoggerPrintWriter printf(final String format, final Object... args) {
- super.printf(format, args);
- return this;
- }
-
- @Override
- public void println() {
- super.println();
- }
-
- @Override
- public void println(final boolean x) {
- super.println(x);
- }
-
- @Override
- public void println(final char x) {
- super.println(x);
- }
-
- @Override
- public void println(final char[] x) {
- super.println(x);
- }
-
- @Override
- public void println(final double x) {
- super.println(x);
- }
-
- @Override
- public void println(final float x) {
- super.println(x);
- }
-
- @Override
- public void println(final int x) {
- super.println(x);
- }
-
- @Override
- public void println(final long x) {
- super.println(x);
- }
-
- @Override
- public void println(final Object x) {
- super.println(x);
- }
-
- @Override
- public void println(final String x) {
- super.println(x);
- }
-
- @Override
- public String toString() {
- return LoggerPrintWriter.class.getSimpleName() + "{stream=" + this.out + '}';
- }
-
- @Override
- public void write(final char[] buf) {
- super.write(buf);
- }
-
- @Override
- public void write(final char[] buf, final int off, final int len) {
- super.write(buf, off, len);
- }
-
- @Override
- public void write(final int c) {
- super.write(c);
- }
-
- @Override
- public void write(final String s) {
- super.write(s);
- }
-
- @Override
- public void write(final String s, final int off, final int len) {
- super.write(s, off, len);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java
deleted file mode 100644
index 5e7ccd8..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.FilterReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.CharBuffer;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.streams.util.CharStreamLogger;
-
-/**
- * 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.
- */
-public class LoggerReader extends FilterReader {
- private static final String FQCN = LoggerReader.class.getName();
-
- 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) {
- super(reader);
- this.logger = new CharStreamLogger(logger, level, marker);
- this.fqcn = fqcn;
- }
-
- @Override
- public void close() throws IOException {
- super.close();
- this.logger.close(this.fqcn);
- }
-
- @Override
- public int read() throws IOException {
- final int c = super.read();
- this.logger.put(this.fqcn, c);
- return c;
- }
-
- @Override
- public int read(final char[] cbuf) throws IOException {
- return read(cbuf, 0, cbuf.length);
- }
-
- @Override
- public int read(final char[] cbuf, final int off, final int len) throws IOException {
- final int charsRead = super.read(cbuf, off, len);
- this.logger.put(this.fqcn, cbuf, off, charsRead);
- return charsRead;
- }
-
- @Override
- public int read(final CharBuffer target) throws IOException {
- final int len = target.remaining();
- final char[] cbuf = new char[len];
- final int charsRead = read(cbuf, 0, len);
- if (charsRead > 0) {
- target.put(cbuf, 0, charsRead);
- }
- return charsRead;
- }
-
- @Override
- public String toString() {
- return LoggerReader.class.getSimpleName() + "{stream=" + this.in + '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerStreams.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerStreams.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerStreams.java
deleted file mode 100644
index bef87b5..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerStreams.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-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.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-public class LoggerStreams {
-
- 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 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 BufferedBuilder marker(final Marker marker) {
- return new BufferedBuilder(this.logger, this.level, marker, this.size);
- }
-
- public BufferedBuilder size(final int size) {
- return new BufferedBuilder(this.logger, this.level, this.marker, size);
- }
- }
-
- public static class Builder {
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
-
- Builder(final ExtendedLogger logger, final Level level, final Marker marker) {
- this.logger = logger;
- this.level = level;
- this.marker = marker;
- }
-
- public BufferedBuilder buffered() {
- return new BufferedBuilder(this.logger, this.level, this.marker, 0);
- }
-
- public LoggerFilterWriter create(final Writer writer) {
- return new LoggerFilterWriter(writer, this.logger, this.level, this.marker);
- }
-
- public Builder marker(final Marker marker) {
- return new Builder(this.logger, this.level, marker);
- }
-
- public PrintingBuilder printing() {
- return new PrintingBuilder(this.logger, this.level, this.marker, false);
- }
- }
-
- public static class PrintingBuilder {
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
- private final boolean autoFlush;
-
- 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 PrintingBuilder autoFlush() {
- return autoFlush(true);
- }
-
- public PrintingBuilder autoFlush(final boolean autoFlush) {
- return new PrintingBuilder(this.logger, this.level, this.marker, autoFlush);
- }
-
- public LoggerPrintStream create(final OutputStream out) {
- return new LoggerPrintStream(out, this.autoFlush, this.logger, this.level, this.marker);
- }
-
- 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 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 static Builder debug(final ExtendedLogger logger) {
- return new Builder(logger, Level.DEBUG, null);
- }
-
- public static Builder error(final ExtendedLogger logger) {
- return new Builder(logger, Level.ERROR, null);
- }
-
- public static Builder fatal(final ExtendedLogger logger) {
- return new Builder(logger, Level.FATAL, null);
- }
-
- public static Builder info(final ExtendedLogger logger) {
- return new Builder(logger, Level.INFO, null);
- }
-
- public static Builder trace(final ExtendedLogger logger) {
- return new Builder(logger, Level.TRACE, null);
- }
-
- 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/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java
deleted file mode 100644
index 68fdc83..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.streams.util.CharStreamLogger;
-
-/**
- * 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.
- */
-public class LoggerWriter extends Writer {
- private static final String FQCN = LoggerWriter.class.getName();
-
- 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) {
- this.logger = new CharStreamLogger(logger, level, marker);
- this.fqcn = fqcn;
- }
-
- @Override
- public void close() throws IOException {
- this.logger.close(this.fqcn);
- }
-
- @Override
- public void flush() throws IOException {
- // do nothing
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName() + "[fqcn=" + this.fqcn + ", logger=" + this.logger + "]";
- }
-
- @Override
- public void write(final char[] cbuf) throws IOException {
- this.logger.put(this.fqcn, cbuf, 0, cbuf.length);
- }
-
- @Override
- public void write(final char[] cbuf, final int off, final int len) throws IOException {
- this.logger.put(this.fqcn, cbuf, off, len);
- }
-
- @Override
- public void write(final int c) throws IOException {
- this.logger.put(this.fqcn, (char) c);
- }
-
- @Override
- public void write(final String str) throws IOException {
- this.logger.put(this.fqcn, str, 0, str.length());
- }
-
- @Override
- public void write(final String str, final int off, final int len) throws IOException {
- this.logger.put(this.fqcn, str, off, len);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/ByteStreamLogger.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/ByteStreamLogger.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/ByteStreamLogger.java
deleted file mode 100644
index 106934c..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/ByteStreamLogger.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-public class ByteStreamLogger {
- private class ByteBufferInputStream extends InputStream {
-
- @Override
- public int read() throws IOException {
- ByteStreamLogger.this.buf.flip();
- int result = -1;
- if (ByteStreamLogger.this.buf.limit() > 0) {
- result = ByteStreamLogger.this.buf.get() & 0xFF;
- }
- ByteStreamLogger.this.buf.compact();
- return result;
- }
-
- @Override
- public int read(final byte[] bytes, final int off, final int len) throws IOException {
- ByteStreamLogger.this.buf.flip();
- int result = -1;
- if (ByteStreamLogger.this.buf.limit() > 0) {
- result = Math.min(len, ByteStreamLogger.this.buf.limit());
- ByteStreamLogger.this.buf.get(bytes, off, result);
- }
- ByteStreamLogger.this.buf.compact();
- return result;
- }
- }
-
- private static final int BUFFER_SIZE = 1024;
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
- private final ByteBufferInputStream inputStream;
- private final InputStreamReader reader;
- private final char[] msgBuf = new char[BUFFER_SIZE];
- private final StringBuilder msg = new StringBuilder();
- private boolean closed;
-
- private final ByteBuffer buf = ByteBuffer.allocate(BUFFER_SIZE);
-
- public ByteStreamLogger(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset) {
- this.logger = logger;
- this.level = level;
- this.marker = marker;
- this.inputStream = new ByteBufferInputStream();
- this.reader = new InputStreamReader(this.inputStream, charset);
- }
-
- public void close(final String fqcn) {
- synchronized (this.msg) {
- this.closed = true;
- logEnd(fqcn);
-// in.close();
- }
- }
-
- private void extractMessages(final String fqcn) throws IOException {
- if (this.closed) {
- return;
- }
- int read = this.reader.read(this.msgBuf);
- while (read > 0) {
- int off = 0;
- for (int pos = 0; pos < read; pos++) {
- switch (this.msgBuf[pos]) {
- case '\r':
- this.msg.append(this.msgBuf, off, pos - off);
- off = pos + 1;
- break;
- case '\n':
- this.msg.append(this.msgBuf, off, pos - off);
- off = pos + 1;
- log(fqcn);
- break;
- }
- }
- this.msg.append(this.msgBuf, off, read - off);
- read = this.reader.read(this.msgBuf);
- }
- }
-
- private void log(final String fqcn) {
- // convert to string now so async loggers work
- this.logger.logIfEnabled(fqcn, this.level, this.marker, this.msg.toString());
- this.msg.setLength(0);
- }
-
- private void logEnd(final String fqcn) {
- if (this.msg.length() > 0) {
- log(fqcn);
- }
- }
-
- public void put(final String fqcn, final byte[] b, final int off, final int len) throws IOException {
- int curOff = off;
- int curLen = len;
- if (curLen >= 0) {
- synchronized (this.msg) {
- while (curLen > this.buf.remaining()) {
- final int remaining = this.buf.remaining();
- this.buf.put(b, curOff, remaining);
- curLen -= remaining;
- curOff += remaining;
- extractMessages(fqcn);
- }
- this.buf.put(b, curOff, curLen);
- extractMessages(fqcn);
- }
- } else {
- logEnd(fqcn);
- }
- }
-
- public void put(final String fqcn, final int b) throws IOException {
- if (b >= 0) {
- synchronized (this.msg) {
- this.buf.put((byte) (b & 0xFF));
- extractMessages(fqcn);
- }
- } else {
- logEnd(fqcn);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/CharStreamLogger.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/CharStreamLogger.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/CharStreamLogger.java
deleted file mode 100644
index ffe2c17..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/util/CharStreamLogger.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams.util;
-
-import java.nio.CharBuffer;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-public class CharStreamLogger {
- private final ExtendedLogger logger;
- private final Level level;
- private final Marker marker;
- private final StringBuilder msg = new StringBuilder();
- private boolean closed = false;
-
- public CharStreamLogger(final ExtendedLogger logger, final Level level, final Marker marker) {
- this.logger = logger;
- this.level = level;
- this.marker = marker;
- }
-
- public void close(final String fqcn) {
- synchronized (this.msg) {
- this.closed = true;
- logEnd(fqcn);
- }
- }
-
- private void log(final String fqcn) {
- // convert to string now so async loggers work
- this.logger.logIfEnabled(fqcn, this.level, this.marker, this.msg.toString());
- this.msg.setLength(0);
- }
-
- private void logEnd(final String fqcn) {
- if (this.msg.length() > 0) {
- log(fqcn);
- }
- }
-
- public void put(final String fqcn, final char[] cbuf, final int off, final int len) {
- put(fqcn, CharBuffer.wrap(cbuf), off, len);
- }
-
- public void put(final String fqcn, final CharSequence str, final int off, final int len) {
- if (len >= 0) {
- synchronized (this.msg) {
- if (this.closed) {
- return;
- }
- int start = off;
- final int end = off + len;
- for (int pos = off; pos < end; pos++) {
- final char c = str.charAt(pos);
- switch (c) {
- case '\r':
- case '\n':
- this.msg.append(str, start, pos);
- start = pos + 1;
- if (c == '\n') {
- log(fqcn);
- }
- break;
- }
- }
- this.msg.append(str, start, end);
- }
- } else {
- logEnd(fqcn);
- }
- }
-
- public void put(final String fqcn, final int c) {
- if (c >= 0) {
- synchronized (this.msg) {
- if (this.closed) {
- return;
- }
- switch (c) {
- case '\n':
- log(fqcn);
- break;
- case '\r':
- break;
- default:
- this.msg.append((char) c);
- }
- }
- } else {
- logEnd(fqcn);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerOutputStreamTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerOutputStreamTest.java
deleted file mode 100644
index 9108794..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerOutputStreamTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-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;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public abstract class AbstractLoggerOutputStreamTest extends AbstractStreamTest {
- protected OutputStream out;
- protected ByteArrayOutputStream wrapped;
-
- protected abstract ByteArrayOutputStream createOutputStream();
-
- protected abstract OutputStream createOutputStreamWrapper();
-
- @Before
- public void createStream() {
- this.wrapped = createOutputStream();
- this.out = createOutputStreamWrapper();
- }
-
- @Test
- public void testClose_HasRemainingData() throws IOException {
- this.out.write(FIRST.getBytes());
- assertMessages();
- this.out.close();
- assertMessages(FIRST);
- if (this.wrapped != null) {
- assertEquals(FIRST, this.wrapped.toString());
- }
- }
-
- @Test
- public void testClose_NoRemainingData() throws IOException {
- this.out.close();
- assertMessages();
- if (this.wrapped != null) {
- assertEquals("", this.wrapped.toString());
- }
- }
-
- @Test
- public void testFlush() throws IOException {
- final OutputStream out = EasyMock.createMock("out", OutputStream.class);
- out.flush(); // expect the flush to come through to the mocked OutputStream
- out.close();
- replay(out);
-
- final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
- los.flush();
- los.close();
- verify(out);
- }
-
- @Test
- public void testWrite_ByteArray() throws Exception {
- final byte[] bytes = "byte[]".getBytes();
- this.out.write(bytes);
- assertMessages();
- this.out.write('\n');
- assertMessages("byte[]");
- if (this.wrapped != null) {
- assertEquals("byte[]\n", this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_ByteArray_Offset_Length() throws Exception {
- final byte[] bytes = "byte[]".getBytes();
- final int middle = bytes.length / 2;
- final int length = bytes.length - middle;
- final String right = new String(bytes, middle, length);
- this.out.write(bytes, middle, length);
- assertMessages();
- this.out.write('\n');
- assertMessages(right);
- if (this.wrapped != null) {
- assertEquals("byte[]".substring(middle, bytes.length) + '\n', this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_IgnoresWindowsNewline() throws IOException {
- this.out.write(FIRST.getBytes());
- this.out.write("\r\n".getBytes());
- this.out.write(LAST.getBytes());
- this.out.close();
- assertMessages(FIRST, LAST);
- if (this.wrapped != null) {
- assertEquals(FIRST + "\r\n" + LAST, this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_Int() throws Exception {
- for (final byte b : "int".getBytes()) {
- this.out.write(b);
- assertMessages();
- }
- this.out.write('\n');
- assertMessages("int");
- if (this.wrapped != null) {
- assertEquals("int" + '\n', this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_MultipleLines() throws IOException {
- this.out.write((FIRST + '\n' + LAST + '\n').getBytes());
- assertMessages(FIRST, LAST);
- if (this.wrapped != null) {
- assertEquals(FIRST + '\n' + LAST + '\n', this.wrapped.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerWriterTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerWriterTest.java
deleted file mode 100644
index 7b19495..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractLoggerWriterTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-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;
-import java.io.Writer;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-
-public abstract class AbstractLoggerWriterTest extends AbstractStreamTest {
- protected StringWriter wrapped;
- protected Writer writer;
-
- @Before
- public void createStream() {
- this.wrapped = createWriter();
- this.writer = createWriterWrapper();
- }
-
- protected abstract StringWriter createWriter();
-
- protected abstract Writer createWriterWrapper();
-
- @Test
- public void testClose_HasRemainingData() throws IOException {
- this.writer.write(FIRST);
- assertMessages();
- this.writer.close();
- assertMessages(FIRST);
- if (this.wrapped != null) {
- assertEquals(FIRST, this.wrapped.toString());
- }
- }
-
- @Test
- public void testClose_NoRemainingData() throws IOException {
- this.writer.close();
- assertMessages();
- if (this.wrapped != null) {
- assertEquals("", this.wrapped.toString());
- }
- }
-
- @Test
- public void testFlush() throws IOException {
- final OutputStream out = EasyMock.createMock(OutputStream.class);
- out.flush(); // expect the flush to come through to the mocked OutputStream
- out.close();
- replay(out);
-
- final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
- los.flush();
- los.close();
- verify(out);
- }
-
- @Test
- public void testWrite_Character() throws Exception {
- for (final char c : FIRST.toCharArray()) {
- this.writer.write(c);
- assertMessages();
- }
- this.writer.write('\n');
- assertMessages(FIRST);
- if (this.wrapped != null) {
- assertEquals(FIRST + '\n', this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_CharArray() throws Exception {
- final char[] chars = FIRST.toCharArray();
- this.writer.write(chars);
- assertMessages();
- this.writer.write('\n');
- assertMessages(FIRST);
- if (this.wrapped != null) {
- assertEquals(FIRST + '\n', this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_CharArray_Offset_Length() throws Exception {
- final char[] chars = FIRST.toCharArray();
- final int middle = chars.length / 2;
- final int length = chars.length - middle;
- final String right = new String(chars, middle, length);
- this.writer.write(chars, middle, length);
- assertMessages();
- this.writer.write('\n');
- assertMessages(right);
- if (this.wrapped != null) {
- assertEquals(FIRST.substring(middle, FIRST.length()) + '\n', this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_IgnoresWindowsNewline() throws IOException {
- this.writer.write(FIRST + "\r\n");
- this.writer.write(LAST);
- this.writer.close();
- assertMessages(FIRST, LAST);
- if (this.wrapped != null) {
- assertEquals(FIRST + "\r\n" + LAST, this.wrapped.toString());
- }
- }
-
- @Test
- public void testWrite_MultipleLines() throws IOException {
- this.writer.write(FIRST + '\n' + LAST + '\n');
- assertMessages(FIRST, LAST);
- if (this.wrapped != null) {
- assertEquals(FIRST + '\n' + LAST + '\n', this.wrapped.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractStreamTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractStreamTest.java
deleted file mode 100644
index 3fd6658..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/AbstractStreamTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.logging.log4j.streams;
-
-import static org.hamcrest.core.StringStartsWith.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Before;
-import org.junit.ClassRule;
-
-public abstract class AbstractStreamTest {
-
- protected static Logger getLogger() {
- return getExtendedLogger();
- }
-
- protected static ExtendedLogger getExtendedLogger() {
- return ctx.getLogger("UnitTestLogger");
- }
-
- protected final static String NEWLINE = System.getProperty("line.separator");
- protected final static Level LEVEL = Level.ERROR;
- protected final static String FIRST = "first";
-
- protected final static String LAST = "last";
-
- @ClassRule
- public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-unit-test.xml");
-
- protected void assertMessages(final String... messages) {
- final List<String> actualMsgs = ((ListAppender) ctx.getAppender("UnitTest")).getMessages();
- assertEquals("Unexpected number of results.", messages.length, actualMsgs.size());
- for (int i = 0; i < messages.length; i++) {
- final String start = LEVEL.name() + ' ' + messages[i];
- assertThat(actualMsgs.get(i), startsWith(start));
- }
- }
-
- @Before
- public void clearAppender() {
- ((ListAppender) ctx.getAppender("UnitTest")).clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java
deleted file mode 100644
index 079deb1..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class LoggerBufferedInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
-
- private LoggerBufferedInputStream logIn;
-
- @Test
- public void close() throws Exception {
- this.logIn.read();
- assertMessages("before close", 3, "close");
- this.logIn.close();
- assertMessages("after close", 4, "close");
- }
-
- @Test
- public void read() throws Exception {
- this.logIn.read();
-
- assertMessages("read", 3, "read");
- this.logIn.close();
- }
-
- @Test
- public void readBytes() throws Exception {
- this.logIn.read(new byte[2]);
-
- assertMessages("read", 3, "readBytes");
- this.logIn.close();
- }
-
- @Test
- public void readBytesOffsetLen() throws Exception {
- this.logIn.read(new byte[2], 0, 2);
-
- assertMessages("read", 3, "readBytesOffsetLen");
- this.logIn.close();
- }
-
- @Before
- public void setupStreams() {
- final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
- this.logIn = new LoggerBufferedInputStream(srcInputStream, getLogger(), LEVEL);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java
deleted file mode 100644
index b11a31a..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-import java.io.InputStream;
-
-import org.apache.logging.log4j.Level;
-
-public class LoggerBufferedInputStreamTest extends LoggerInputStreamTest {
-
- @Override
- protected InputStream createInputStream() {
- return new LoggerBufferedInputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java
deleted file mode 100644
index b723651..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.nio.CharBuffer;
-
-import org.apache.logging.log4j.Level;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LoggerBufferedReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
-
- LoggerBufferedReader logReader;
-
- @Test
- public void close() throws Exception {
- this.logReader.readLine();
- assertMessages("before close", 3, "close");
- this.logReader.close();
- assertMessages("after close", 4, "close");
- }
-
- @Test
- public void read() throws Exception {
- this.logReader.read();
-
- assertMessages("read", 3, "read");
- this.logReader.close();
- }
-
- @Test
- public void readCbuf() throws Exception {
- this.logReader.read(new char[2]);
-
- assertMessages("read", 3, "readCbuf");
- this.logReader.close();
- }
-
- @Test
- public void readCbufOffset() throws Exception {
- this.logReader.read(new char[2], 0, 2);
-
- assertMessages("read", 3, "readCbufOffset");
- this.logReader.close();
- }
-
- @Test
- public void readCharBuffer() throws Exception {
- this.logReader.read(CharBuffer.allocate(2));
-
- assertMessages("read", 3, "readCharBuffer");
- this.logReader.close();
- }
-
- @Test
- public void readLine() throws Exception {
- this.logReader.readLine();
-
- assertMessages("read", 3, "readLine");
- this.logReader.close();
- }
-
- @Before
- public void setupReader() {
- final Reader srcReader = new StringReader("a\nb\nc\nd");
- this.logReader = new LoggerBufferedReader(srcReader, getLogger(), Level.WARN);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java
deleted file mode 100644
index 1e4ecc8..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.BufferedReader;
-import java.io.Reader;
-
-import org.junit.Test;
-
-public class LoggerBufferedReaderTest extends LoggerReaderTest {
- private BufferedReader bufferedReader;
-
- @Override
- protected Reader createReader() {
- return this.bufferedReader = new LoggerBufferedReader(this.wrapped, getExtendedLogger(), LEVEL);
- }
-
- @Test
- public void testReadLine() throws Exception {
- assertEquals("first line", FIRST, this.bufferedReader.readLine());
- assertMessages(FIRST);
- assertEquals("second line", LAST, this.bufferedReader.readLine());
- assertMessages(FIRST, LAST);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterOutputStreamTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterOutputStreamTest.java
deleted file mode 100644
index 5b05775..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterOutputStreamTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-
-import org.apache.logging.log4j.Level;
-
-public class LoggerFilterOutputStreamTest extends AbstractLoggerOutputStreamTest {
-
- @Override
- protected ByteArrayOutputStream createOutputStream() {
- return new ByteArrayOutputStream();
- }
-
- @Override
- protected OutputStream createOutputStreamWrapper() {
- return new LoggerFilterOutputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterWriterTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterWriterTest.java
deleted file mode 100644
index 99a1207..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerFilterWriterTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.logging.log4j.streams;
-
-import java.io.StringWriter;
-import java.io.Writer;
-
-public class LoggerFilterWriterTest extends AbstractLoggerWriterTest {
-
- @Override
- protected StringWriter createWriter() {
- return new StringWriter();
- }
-
- @Override
- protected Writer createWriterWrapper() {
- return new LoggerFilterWriter(this.wrapped, getExtendedLogger(), LEVEL);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java
deleted file mode 100644
index 6037c3e..0000000
--- a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.streams;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.apache.logging.log4j.Level;
-import org.junit.Before;
-import org.junit.Test;
-
-public class LoggerInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
-
- private LoggerInputStream logIn;
-
- @Test
- public void read() throws Exception {
- this.logIn.read();
- assertMessages("before read int size", 0, "read");
- this.logIn.read();
- assertMessages("after read int size", 1, "read");
-
- this.logIn.read(new byte[2]);
- assertMessages("after read bytes size", 2, "read");
-
- this.logIn.read(new byte[2], 0, 2);
- assertMessages("after read bytes offset size", 3, "read");
-
- this.logIn.read();
- assertMessages("before close size", 3, "read");
- this.logIn.close();
- assertMessages("after close size", 4, "read");
- }
-
- @Before
- public void setupStreams() {
- final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
- this.logIn = new LoggerInputStream(srcInputStream, getLogger(), Level.WARN);
- }
-}