You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2015/04/20 05:50:05 UTC
logging-log4j2 git commit: Refactor system err and system out custom
output stream classes to reuse the new CloseShieldOutputStream class for the
console appender.
Repository: logging-log4j2
Updated Branches:
refs/heads/master c958fbaf2 -> c7ea701a3
Refactor system err and system out custom output stream classes to reuse
the new CloseShieldOutputStream class for the console appender.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c7ea701a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c7ea701a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c7ea701a
Branch: refs/heads/master
Commit: c7ea701a3c507af955ba4a9ce3b83f9648a54a2c
Parents: c958fba
Author: Gary Gregory <ga...@gmail.com>
Authored: Sun Apr 19 20:50:02 2015 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Sun Apr 19 20:50:02 2015 -0700
----------------------------------------------------------------------
.../log4j/core/appender/ConsoleAppender.java | 72 +-------------------
1 file changed, 2 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c7ea701a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
index f98a61c..3132d21 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
@@ -183,8 +183,8 @@ public final class ConsoleAppender extends AbstractOutputStreamAppender<OutputSt
PrintStream printStream = null;
try {
printStream = target == Target.SYSTEM_OUT ?
- follow ? new PrintStream(new SystemOutStream(), true, enc) : System.out :
- follow ? new PrintStream(new SystemErrStream(), true, enc) : System.err;
+ follow ? new PrintStream(new CloseShieldOutputStream(System.out), true, enc) : System.out :
+ follow ? new PrintStream(new CloseShieldOutputStream(System.err), true, enc) : System.err;
} catch (final UnsupportedEncodingException ex) { // should never happen
throw new IllegalStateException("Unsupported default encoding " + enc, ex);
}
@@ -247,74 +247,6 @@ public final class ConsoleAppender extends AbstractOutputStreamAppender<OutputSt
}
/**
- * An implementation of OutputStream that redirects to the current System.err.
- */
- private static class SystemErrStream extends OutputStream {
- public SystemErrStream() {
- }
-
- @Override
- public void close() {
- // do not close sys err!
- }
-
- @Override
- public void flush() {
- System.err.flush();
- }
-
- @Override
- public void write(final byte[] b) throws IOException {
- System.err.write(b);
- }
-
- @Override
- public void write(final byte[] b, final int off, final int len)
- throws IOException {
- System.err.write(b, off, len);
- }
-
- @Override
- public void write(final int b) {
- System.err.write(b);
- }
- }
-
- /**
- * An implementation of OutputStream that redirects to the current System.out.
- */
- private static class SystemOutStream extends OutputStream {
- public SystemOutStream() {
- }
-
- @Override
- public void close() {
- // do not close sys out!
- }
-
- @Override
- public void flush() {
- System.out.flush();
- }
-
- @Override
- public void write(final byte[] b) throws IOException {
- System.out.write(b);
- }
-
- @Override
- public void write(final byte[] b, final int off, final int len)
- throws IOException {
- System.out.write(b, off, len);
- }
-
- @Override
- public void write(final int b) throws IOException {
- System.out.write(b);
- }
- }
-
- /**
* Data to pass to factory method.
*/
private static class FactoryData {