logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1587396 [1/2] - in /logging/log4j/log4j2/trunk: ./ log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ log4j-streams/ log4j-streams/src/ log4j-streams/src/main/ log4j-streams/src/main/java/ log4j-streams/src/main/java/org/ log4j-s...
Date Tue, 15 Apr 2014 03:45:01 GMT
Author: mattsicker
Date: Tue Apr 15 03:44:59 2014
New Revision: 1587396

URL: http://svn.apache.org/r1587396
Log:
Add log4j-streams module.

  - See LOG4J2-547
  - Thanks to Bruce Brouwer for the patch!
  - Added finals everywhere to said patch.

Added:
    logging/log4j/log4j2/trunk/log4j-streams/   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/pom.xml   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/CharStreamLogger.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintWriterCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintWriterTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerReaderCallerInfoTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerReaderTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerStreamsCallerInfoTesting.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerWriterTest.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/StreamTesting.java   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/resources/
    logging/log4j/log4j2/trunk/log4j-streams/src/test/resources/log4j2-streams-calling-info.xml   (with props)
    logging/log4j/log4j2/trunk/log4j-streams/src/test/resources/log4j2-streams-unit-test.xml   (with props)
Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
    logging/log4j/log4j2/trunk/pom.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java?rev=1587396&r1=1587395&r2=1587396&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java Tue Apr 15 03:44:59 2014
@@ -39,7 +39,6 @@ import org.apache.logging.log4j.message.
 public class Log4jLogEvent implements LogEvent {
 
     private static final long serialVersionUID = -1351367343806656055L;
-    private static final String NOT_AVAIL = "?";
     private final String fqcnOfLogger;
     private final Marker marker;
     private final Level level;
@@ -313,21 +312,13 @@ public class Log4jLogEvent implements Lo
             return null;
         }
         final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
-        boolean next = false;
-        for (final StackTraceElement element : stackTrace) {
-            final String className = element.getClassName();
-            if (next) {
-                if (fqcnOfLogger.equals(className)) {
-                    continue;
-                }
-                return element;
-            }
-
+        StackTraceElement last = null;
+        for (int i = stackTrace.length - 1; i > 0; i--) {
+            final String className = stackTrace[i].getClassName();
             if (fqcnOfLogger.equals(className)) {
-                next = true;
-            } else if (NOT_AVAIL.equals(className)) {
-                break;
+                return last;
             }
+            last = stackTrace[i];
         }
         return null;
     }

Propchange: logging/log4j/log4j2/trunk/log4j-streams/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 15 03:44:59 2014
@@ -0,0 +1 @@
+*.iml

Added: logging/log4j/log4j2/trunk/log4j-streams/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/pom.xml?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/pom.xml (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/pom.xml Tue Apr 15 03:44:59 2014
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j</artifactId>
+    <version>2.0-rc2-SNAPSHOT</version>
+    <relativePath>../</relativePath>
+  </parent>
+  <artifactId>log4j-streams</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Log4j Streaming Interface</name>
+  <description>Provides the ability to convert streams into log statements</description>
+  <properties>
+    <log4jParentDir>${basedir}/..</log4jParentDir>
+    <docLabel>Streaming Documentation</docLabel>
+    <projectDir>/slf4j-streams</projectDir>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- TEST DEPENDENCIES -->
+
+    <!-- Pull in useful test classes from API -->
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <!-- Include the standard NOTICE and LICENSE -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-remote-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>process</goal>
+            </goals>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-changes-plugin</artifactId>
+        <version>${changes.plugin.version}</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>changes-report</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+        <configuration>
+          <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>2.7</version>
+        <configuration>
+          <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
+          <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
+          <suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
+          <enableRulesSummary>false</enableRulesSummary>
+          <propertyExpansion>basedir=${basedir}</propertyExpansion>
+          <propertyExpansion>licensedir=${log4jParentDir}/checkstyle-header.txt</propertyExpansion>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>${javadoc.plugin.version}</version>
+        <configuration>
+          <bottom> <![CDATA[<p align="center">Copyright &#169; {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br />
+            Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo,
+            and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p>]]></bottom>
+          <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
+               project -->
+          <detectOfflineLinks>false</detectOfflineLinks>
+          <linksource>true</linksource>
+          <tags>
+            <tag>
+              <name>issue</name>
+              <placement>a</placement>
+              <head>JIRA issue:</head>
+            </tag>
+            <tag>
+              <name>doubt</name>
+              <placement>a</placement>
+              <head>Troublesome:</head>
+            </tag>
+            <tag>
+              <name>compare</name>
+              <placement>a</placement>
+              <head>Compare with:</head>
+            </tag>
+          </tags>
+        </configuration>
+        <reportSets>
+          <reportSet>
+            <id>non-aggregate</id>
+            <reports>
+              <report>javadoc</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <version>2.5.2</version>
+        <configuration>
+          <fork>true</fork>
+          <jvmArgs>-Duser.language=en</jvmArgs>
+          <threshold>Normal</threshold>
+          <effort>Default</effort>
+          <excludeFilterFile>${log4jParentDir}/findbugs-exclude-filter.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>2.3</version>
+        <reportSets>
+          <reportSet>
+            <id>non-aggregate</id>
+            <reports>
+              <report>jxr</report>
+            </reports>
+          </reportSet>
+          <reportSet>
+            <id>aggregate</id>
+            <reports>
+              <report>aggregate</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <version>${pmd.plugin.version}</version>
+        <configuration>
+          <targetJdk>${maven.compile.target}</targetJdk>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>cobertura-maven-plugin</artifactId>
+        <version>${cobertura.plugin.version}</version>
+        <reportSets>
+          <reportSet>
+            <!-- Disabled as it makes the site build very slow and causes the performance unit test to fail -->
+            <reports />
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
+

Propchange: logging/log4j/log4j2/trunk/log4j-streams/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,150 @@
+/*
+ * 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.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.LoggerProvider;
+
+public class ByteStreamLogger {
+    private static final int BUFFER_SIZE = 1024;
+
+    private final LoggerProvider logger;
+    private final Level level;
+    private final Marker marker;
+    private final ByteBufferInputStream in;
+    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 LoggerProvider logger, final Level level, final Marker marker, final Charset charset) {
+        this.logger = logger;
+        this.level = level;
+        this.marker = marker;
+        this.in = new ByteBufferInputStream();
+        this.reader = new InputStreamReader(in, charset);
+    }
+
+    public void put(final String fqcn, final int b) throws IOException {
+        if (b >= 0) {
+            synchronized (msg) {
+                buf.put((byte) (b & 0xFF));
+                extractMessages(fqcn);
+            }
+        } else {
+            logEnd(fqcn);
+        }
+    }
+
+    public void put(final String fqcn, final byte[] b, int off, int len) throws IOException {
+        if (len >= 0) {
+            synchronized (msg) {
+                while (len > buf.remaining()) {
+                    final int remaining = buf.remaining();
+                    buf.put(b, off, remaining);
+                    len -= remaining;
+                    off += remaining;
+                    extractMessages(fqcn);
+                }
+                buf.put(b, off, len);
+                extractMessages(fqcn);
+            }
+        } else {
+            logEnd(fqcn);
+        }
+    }
+
+    public void close(final String fqcn) {
+        synchronized (msg) {
+            closed = true;
+            logEnd(fqcn);
+//            in.close();
+        }
+    }
+
+    private void extractMessages(final String fqcn) throws IOException {
+        if (closed) {
+            return;
+        }
+        int read = reader.read(msgBuf);
+        while (read > 0) {
+            int off = 0;
+            for (int pos = 0; pos < read; pos++) {
+                switch (msgBuf[pos]) {
+                case '\r':
+                    msg.append(msgBuf, off, pos - off);
+                    off = pos + 1;
+                    break;
+                case '\n':
+                    msg.append(msgBuf, off, pos - off);
+                    off = pos + 1;
+                    log(fqcn);
+                    break;
+                }
+            }
+            msg.append(msgBuf, off, read - off);
+            read = reader.read(msgBuf);
+        }
+    }
+    
+    private void logEnd(final String fqcn) {
+        if (msg.length() > 0) {
+            log(fqcn);
+        }
+    }
+
+    private void log(final String fqcn) {
+        // convert to string now so async loggers work
+        logger.logIfEnabled(fqcn, level, marker, msg.toString());
+        msg.setLength(0);
+    }
+
+    private class ByteBufferInputStream extends InputStream {
+
+        @Override
+        public int read() throws IOException {
+            buf.flip();
+            int result = -1;
+            if (buf.limit() > 0) {
+                result = buf.get() & 0xFF;
+            }
+            buf.compact();
+            return result;
+        }
+
+        @Override
+        public int read(final byte[] bytes, final int off, final int len) throws IOException {
+            buf.flip();
+            int result = -1;
+            if (buf.limit() > 0) {
+                result = Math.min(len, buf.limit());
+                buf.get(bytes, off, result);
+            }
+            buf.compact();
+            return result;
+        }
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/ByteStreamLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/CharStreamLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/CharStreamLogger.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/CharStreamLogger.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/CharStreamLogger.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,110 @@
+/*
+ * 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.nio.CharBuffer;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+public class CharStreamLogger {
+    private final LoggerProvider logger;
+    private final Level level;
+    private final Marker marker;
+    private final StringBuilder msg = new StringBuilder();
+    private boolean closed = false;
+
+    public CharStreamLogger(final LoggerProvider logger, final Level level, final Marker marker) {
+        this.logger = logger;
+        this.level = level;
+        this.marker = marker;
+    }
+
+    public void put(final String fqcn, final int c) {
+        if (c >= 0) {
+            synchronized (msg) {
+                if (closed) {
+                    return;
+                }
+                switch (c) {
+                case '\n':
+                    log(fqcn);
+                    break;
+                case '\r':
+                    break;
+                default:
+                    msg.append((char) c);
+                }
+            }
+        } else {
+            logEnd(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 (msg) {
+                if (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':
+                        msg.append(str, start, pos);
+                        start = pos + 1;
+                        if (c == '\n') {
+                            log(fqcn);
+                        }
+                        break;
+                    }
+                }
+                msg.append(str, start, end);
+            }
+        } else {
+            logEnd(fqcn);
+        }
+    }
+
+    public void close(final String fqcn) {
+        synchronized (msg) {
+            closed = true;
+            logEnd(fqcn);
+        }
+    }
+
+    private void logEnd(final String fqcn) {
+        if (msg.length() > 0) {
+            log(fqcn);
+        }
+    }
+
+    private void log(final String fqcn) {
+        logger.logIfEnabled(fqcn, level, marker, msg.toString()); // convert to string now so async loggers
+                                                         // work
+        msg.setLength(0);
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/CharStreamLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,105 @@
+/*
+ * 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.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+public class LoggerBufferedInputStream extends BufferedInputStream {
+    private static final String FQCN = LoggerBufferedInputStream.class.getName();
+
+    public LoggerBufferedInputStream(final InputStream in, final Logger logger, final Level level) {
+        this(in, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final Logger logger, final Level level) {
+        this(in, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final Logger logger, final Level level, final Marker marker) {
+        this(in, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final Logger logger, final Level level, final Marker marker) {
+        this(in, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final int sz, final Logger logger, final Level level) {
+        this(in, sz, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int sz, final Logger logger, final Level level) {
+        this(in, charset, sz, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final int sz, final Logger logger, final Level level, final Marker marker) {
+        this(in, sz, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int sz, final Logger logger, final Level level, final Marker marker) {
+        this(in, charset, sz, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        this(in, Charset.defaultCharset(), logger, fqcn, level, marker);
+    }
+
+    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final LoggerProvider 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 int sz, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        this(in, Charset.defaultCharset(), sz, logger, fqcn, level, marker);
+    }
+    
+    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int sz, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        super(new LoggerInputStream(in, charset, logger, fqcn, level, marker), sz);
+    }
+    
+    @Override
+    public void close() throws IOException {
+        super.close();
+    }
+    
+    @Override
+    public synchronized int read() throws IOException {
+        return super.read();
+    }
+    
+    @Override
+    public int read(final byte[] b) throws IOException {
+        return super.read(b, 0, b.length);
+    }
+    
+    @Override
+    public synchronized int read(final byte[] b, final int off, final int len) throws IOException {
+        return super.read(b, off, len);
+    }
+
+    @Override
+    public String toString() {
+        return LoggerBufferedInputStream.class.getSimpleName() + "{stream=" + in + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,92 @@
+/*
+ * 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.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.CharBuffer;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+public class LoggerBufferedReader extends BufferedReader {
+    private static final String FQCN = LoggerBufferedReader.class.getName();
+
+    public LoggerBufferedReader(final Reader reader, final Logger logger, final Level level) {
+        this(reader, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerBufferedReader(final Reader reader, final Logger logger, final Level level, final Marker marker) {
+        this(reader, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerBufferedReader(final Reader reader, final int sz, final Logger logger, final Level level) {
+        this(reader, sz, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerBufferedReader(final Reader reader, final int sz, final Logger logger, final Level level, final Marker marker) {
+        this(reader, sz, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerBufferedReader(final Reader reader, final LoggerProvider 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 sz, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        super(new LoggerReader(reader, logger, FQCN, level, marker), sz);
+    }
+    
+    @Override
+    public void close() throws IOException {
+        super.close();
+    }
+    
+    @Override
+    public int read() throws IOException {
+        return super.read();
+    }
+    
+    @Override
+    public int read(final char[] cbuf) throws IOException {
+        return super.read(cbuf, 0, cbuf.length);
+    }
+    
+    @Override
+    public int read(final char[] cbuf, final int off, final int len) throws IOException {
+        return super.read(cbuf, off, len);
+    }
+    
+    @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 readLine() throws IOException {
+        return super.readLine();
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,91 @@
+/*
+ * 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.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+/**
+ * Input stream that 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 Logger logger, final Level level) {
+        this(in, Charset.defaultCharset(), (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerInputStream(final InputStream in, final Charset charset, final Logger logger, final Level level) {
+        this(in, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerInputStream(final InputStream in, final Logger logger, final Level level, final Marker marker) {
+        this(in, Charset.defaultCharset(), (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerInputStream(final InputStream in, final Charset charset, final Logger logger, final Level level, final Marker marker) {
+        this(in, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerInputStream(final InputStream in, final Charset charset, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        super(in);
+        this.logger = new ByteStreamLogger(logger, level, marker, charset);
+        this.fqcn = fqcn;
+    }
+
+    @Override
+    public int read() throws IOException {
+        final int b = super.read();
+        logger.put(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);
+        logger.put(fqcn, b, off, bytesRead);
+        return bytesRead;
+    }
+
+    @Override
+    public void close() throws IOException {
+        logger.close(fqcn);
+        super.close();
+    }
+
+    @Override
+    public String toString() {
+        return LoggerInputStream.class.getSimpleName() + "{stream=" + in + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,125 @@
+/*
+ * 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.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+/**
+ * Output stream that 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 OutputStream out;
+    private final ByteStreamLogger logger;
+    private final String fqcn;
+
+    public LoggerOutputStream(final Logger logger, final Level level) {
+        this(null, Charset.defaultCharset(), (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerOutputStream(final Charset charset, final Logger logger, final Level level) {
+        this(null, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerOutputStream(final Logger logger, final Level level, final Marker marker) {
+        this(null, Charset.defaultCharset(), (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerOutputStream(final Charset charset, final Logger logger, final Level level, final Marker marker) {
+        this(null, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerOutputStream(final OutputStream out, final Logger logger, final Level level) {
+        this(out, Charset.defaultCharset(), (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerOutputStream(final OutputStream out, final Charset charset, final Logger logger, final Level level) {
+        this(out, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerOutputStream(final OutputStream out, final Logger logger, final Level level, final Marker marker) {
+        this(out, Charset.defaultCharset(), (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerOutputStream(final OutputStream out, final Charset charset, final Logger logger, final Level level, final Marker marker) {
+        this(out, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerOutputStream(final OutputStream out, final Charset charset, final LoggerProvider logger, final String fqcn, final Level level,
+            final Marker marker) {
+        this.out = out;
+        this.logger = new ByteStreamLogger(logger, level, marker, charset);
+        this.fqcn = fqcn;
+    }
+
+    @Override
+    public void write(final int b) throws IOException {
+        if (out != null) {
+            out.write(b);
+        }
+        logger.put(fqcn, (byte) (b & 0xFF));
+    }
+
+    @Override
+    public void write(final byte[] b) throws IOException {
+        if (out != null) {
+            out.write(b);
+        }
+        logger.put(fqcn, b, 0, b.length);
+    }
+
+    @Override
+    public void write(final byte[] b, final int off, final int len) throws IOException {
+        if (out != null) {
+            out.write(b, off, len);
+        }
+        logger.put(fqcn, b, off, len);
+    }
+
+    @Override
+    public void flush() throws IOException {
+        if (out != null) {
+            out.flush();
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (out != null) {
+            out.close();
+        }
+        logger.close(fqcn);
+    }
+
+    @Override
+    public String toString() {
+        return LoggerOutputStream.class.getSimpleName() + "{stream=" + out + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,273 @@
+/*
+ * 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.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+/**
+ * Output stream that 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 Logger logger, final Level level) {
+        this(null, false, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintStream(final Charset charset, final Logger logger, final Level level) throws UnsupportedEncodingException {
+        this(null, false, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintStream(final Logger logger, final Level level, final Marker marker) {
+        this(null, false, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintStream(final Charset charset, final Logger logger, final Level level, final Marker marker) throws UnsupportedEncodingException {
+        this(null, false, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final Logger logger, final Level level) {
+        this(out, false, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final Charset charset, final Logger logger, final Level level) throws UnsupportedEncodingException {
+        this(out, false, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final Logger logger, final Level level, final Marker marker) {
+        this(out, false, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final Charset charset, final Logger logger, final Level level, final Marker marker)
+            throws UnsupportedEncodingException {
+        this(out, false, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Logger logger, final Level level) {
+        this(out, autoFlush, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset, final Logger logger, final Level level)
+            throws UnsupportedEncodingException {
+        this(out, autoFlush, charset, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Logger logger, final Level level, final Marker marker) {
+        this(out, autoFlush, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset, final Logger logger, final Level level, final Marker marker)
+            throws UnsupportedEncodingException {
+        this(out, autoFlush, charset, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        super(new LoggerOutputStream(out, Charset.defaultCharset(), logger, fqcn, level, marker), autoFlush);
+    }
+
+    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset, final LoggerProvider logger, final String fqcn,
+            final Level level, final Marker marker) throws UnsupportedEncodingException {
+        super(new LoggerOutputStream(out, charset, logger, fqcn, level, marker), autoFlush, charset.name());
+    }
+
+    @Override
+    public void write(final int b) {
+        super.write(b);
+    }
+
+    @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 flush() {
+        super.flush();
+    }
+
+    @Override
+    public void close() {
+        super.close();
+    }
+
+    @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 int i) {
+        super.print(i);
+    }
+
+    @Override
+    public void print(final long l) {
+        super.print(l);
+    }
+
+    @Override
+    public void print(final float f) {
+        super.print(f);
+    }
+
+    @Override
+    public void print(final double d) {
+        super.print(d);
+    }
+
+    @Override
+    public void print(final char[] s) {
+        super.print(s);
+    }
+
+    @Override
+    public void print(final String s) {
+        super.print(s);
+    }
+
+    @Override
+    public void print(final Object obj) {
+        super.print(obj);
+    }
+
+    @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 int x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final long x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final float x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final double x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final char[] x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final String x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final Object x) {
+        super.println(x);
+    }
+
+    @Override
+    public LoggerPrintStream printf(final String format, final Object... args) {
+        super.printf(format, args);
+        return this;
+    }
+
+    @Override
+    public LoggerPrintStream printf(final Locale l, final String format, final Object... args) {
+        super.printf(l, format, args);
+        return this;
+    }
+
+    @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 LoggerPrintStream format(final String format, final Object... args) {
+        super.format(format, args);
+        return this;
+    }
+
+    @Override
+    public LoggerPrintStream format(final Locale l, final String format, final Object... args) {
+        super.format(l, format, args);
+        return this;
+    }
+
+    @Override
+    public boolean checkError() {
+        return super.checkError();
+    }
+
+    @Override
+    public String toString() {
+        return LoggerPrintStream.class.getSimpleName() + "{stream=" + out + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,247 @@
+/*
+ * 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.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+/**
+ * Print Writer that 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. 
+ */
+public class LoggerPrintWriter extends PrintWriter {
+    private static final String FQCN = LoggerPrintWriter.class.getName();
+
+    public LoggerPrintWriter(final Logger logger, final Level level) {
+        this(null, false, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintWriter(final Logger logger, final Level level, final Marker marker) {
+        this(null, false, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintWriter(final Writer writer, final Logger logger, final Level level) {
+        this(writer, false, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintWriter(final Writer writer, final Logger logger, final Level level, final Marker marker) {
+        this(writer, false, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final Logger logger, final Level level) {
+        this(writer, autoFlush, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final Logger logger, final Level level, final Marker marker) {
+        this(writer, autoFlush, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final LoggerProvider logger, final String fqcn,
+            final Level level, final Marker marker) {
+        super(new LoggerWriter(writer, logger, fqcn, level, marker), autoFlush);
+    }
+
+    @Override
+    public void write(final int c) {
+        super.write(c);
+    }
+    
+    @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 String s) {
+        super.write(s);
+    }
+    
+    @Override
+    public void write(final String s, final int off, final int len) {
+        super.write(s, off, len);
+    }
+
+    @Override
+    public void flush() {
+        super.flush();
+    }
+
+    @Override
+    public void close() {
+        super.close();
+    }
+
+    @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 int i) {
+        super.print(i);
+    }
+
+    @Override
+    public void print(final long l) {
+        super.print(l);
+    }
+
+    @Override
+    public void print(final float f) {
+        super.print(f);
+    }
+
+    @Override
+    public void print(final double d) {
+        super.print(d);
+    }
+
+    @Override
+    public void print(final char[] s) {
+        super.print(s);
+    }
+
+    @Override
+    public void print(final String s) {
+        super.print(s);
+    }
+
+    @Override
+    public void print(final Object obj) {
+        super.print(obj);
+    }
+
+    @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 int x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final long x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final float x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final double x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final char[] x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final String x) {
+        super.println(x);
+    }
+
+    @Override
+    public void println(final Object x) {
+        super.println(x);
+    }
+
+    @Override
+    public LoggerPrintWriter printf(final String format, final Object... args) {
+        super.printf(format, args);
+        return this;
+    }
+
+    @Override
+    public LoggerPrintWriter printf(final Locale l, final String format, final Object... args) {
+        super.printf(l, format, args);
+        return this;
+    }
+
+    @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 LoggerPrintWriter format(final String format, final Object... args) {
+        super.format(format, args);
+        return this;
+    }
+
+    @Override
+    public LoggerPrintWriter format(final Locale l, final String format, final Object... args) {
+        super.format(l, format, args);
+        return this;
+    }
+    
+    @Override
+    public boolean checkError() {
+        return super.checkError();
+    }
+
+    @Override
+    public String toString() {
+        return LoggerPrintWriter.class.getSimpleName() + "{stream=" + out + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerPrintWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,95 @@
+/*
+ * 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.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+/**
+ * Writer that 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 Logger logger, final Level level) {
+        this(reader, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerReader(final Reader reader, final Logger logger, final Level level, final Marker marker) {
+        this(reader, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerReader(final Reader reader, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        super(reader);
+        this.logger = new CharStreamLogger(logger, level, marker);
+        this.fqcn = fqcn;
+    }
+
+    @Override
+    public int read() throws IOException {
+        final int c = super.read();
+        logger.put(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);
+        logger.put(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 void close() throws IOException {
+        super.close();
+        logger.close(fqcn);
+    }
+
+    @Override
+    public String toString() {
+        return LoggerReader.class.getSimpleName() + "{stream=" + in + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,121 @@
+/*
+ * 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.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.spi.LoggerProvider;
+
+/**
+ * Writer that 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 Writer writer;
+    private final CharStreamLogger logger;
+    private final String fqcn;
+
+    public LoggerWriter(final Logger logger, final Level level) {
+        this(null, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerWriter(final Logger logger, final Level level, final Marker marker) {
+        this(null, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerWriter(final Writer writer, final Logger logger, final Level level) {
+        this(writer, (LoggerProvider) logger, FQCN, level, null);
+    }
+
+    public LoggerWriter(final Writer writer, final Logger logger, final Level level, final Marker marker) {
+        this(writer, (LoggerProvider) logger, FQCN, level, marker);
+    }
+
+    public LoggerWriter(final Writer writer, final LoggerProvider logger, final String fqcn, final Level level, final Marker marker) {
+        this.writer = writer;
+        this.logger = new CharStreamLogger(logger, level, marker);
+        this.fqcn = fqcn;
+    }
+
+    @Override
+    public void write(final int c) throws IOException {
+        if (writer != null) {
+            writer.write(c);
+        }
+        logger.put(fqcn, (char) c);
+    }
+
+    @Override
+    public void write(final char[] cbuf) throws IOException {
+        if (writer != null) {
+            writer.write(cbuf);
+        }
+        logger.put(fqcn, cbuf, 0, cbuf.length);
+    }
+
+    @Override
+    public void write(final char[] cbuf, final int off, final int len) throws IOException {
+        if (writer != null) {
+            writer.write(cbuf, off, len);
+        }
+        logger.put(fqcn, cbuf, off, len);
+    }
+
+    @Override
+    public void write(final String str) throws IOException {
+        if (writer != null) {
+            writer.write(str);
+        }
+        logger.put(fqcn, str, 0, str.length());
+    }
+
+    @Override
+    public void write(final String str, final int off, final int len) throws IOException {
+        if (writer != null) {
+            writer.write(str, off, len);
+        }
+        logger.put(fqcn, str, off, len);
+    }
+
+    @Override
+    public void flush() throws IOException {
+        if (writer != null) {
+            writer.flush();
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (writer != null) {
+            writer.close();
+        }
+        logger.close(fqcn);
+    }
+
+    @Override
+    public String toString() {
+        return LoggerWriter.class.getSimpleName() + "{stream=" + writer + '}';
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,66 @@
+/*
+ * 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;
+    
+    @Before
+    public void setupStreams() {
+        final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
+        logIn = new LoggerBufferedInputStream(srcInputStream, getLogger(), LEVEL);
+    }
+    
+    @Test
+    public void read() throws Exception {
+        logIn.read();
+
+        assertMessages("read", 3, "read");
+        logIn.close();
+    }
+
+    @Test
+    public void readBytes() throws Exception {
+        logIn.read(new byte[2]);
+
+        assertMessages("read", 3, "readBytes");
+        logIn.close();
+    }
+
+    @Test
+    public void readBytesOffsetLen() throws Exception {
+        logIn.read(new byte[2], 0, 2);
+
+        assertMessages("read", 3, "readBytesOffsetLen");
+        logIn.close();
+    }
+
+    @Test
+    public void close() throws Exception {
+        logIn.read();
+        assertMessages("before close", 3, "close");
+        logIn.close();
+        assertMessages("after close", 4, "close");
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamCallerInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,29 @@
+/*
+ * 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(wrapped, getLogger(), Level.ERROR);
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,84 @@
+/*
+ * 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;
+    
+    @Before
+    public void setupReader() {
+        final Reader srcReader = new StringReader("a\nb\nc\nd");
+        logReader = new LoggerBufferedReader(srcReader, getLogger(), Level.WARN);
+    }
+
+    @Test
+    public void read() throws Exception {
+        logReader.read();
+
+        assertMessages("read", 3, "read");
+        logReader.close();
+    }
+
+    @Test
+    public void readCbuf() throws Exception {
+        logReader.read(new char[2]);
+
+        assertMessages("read", 3, "readCbuf");
+        logReader.close();
+    }
+
+    @Test
+    public void readCbufOffset() throws Exception {
+        logReader.read(new char[2], 0, 2);
+
+        assertMessages("read", 3, "readCbufOffset");
+        logReader.close();
+    }
+
+    @Test
+    public void readCharBuffer() throws Exception {
+        logReader.read(CharBuffer.allocate(2));
+
+        assertMessages("read", 3, "readCharBuffer");
+        logReader.close();
+    }
+
+    @Test
+    public void readLine() throws Exception {
+        logReader.readLine();
+
+        assertMessages("read", 3, "readLine");
+        logReader.close();
+    }
+
+    @Test
+    public void close() throws Exception {
+        logReader.readLine();
+        assertMessages("before close", 3, "close");
+        logReader.close();
+        assertMessages("after close", 4, "close");
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderCallerInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,41 @@
+/*
+ * 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 reader;
+    
+    @Override
+    protected Reader createReader() {
+        return this.reader = new LoggerBufferedReader(wrapped, getLogger(), LEVEL);
+    }
+
+    @Test
+    public void testReadLine() throws Exception {
+        assertEquals("first line", FIRST, reader.readLine());
+        assertMessages(FIRST);
+        assertEquals("second line", LAST, reader.readLine());
+        assertMessages(FIRST, LAST);
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerBufferedReaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java?rev=1587396&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java (added)
+++ logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java Tue Apr 15 03:44:59 2014
@@ -0,0 +1,54 @@
+/*
+ * 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;
+    
+    @Before
+    public void setupStreams() {
+        final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
+        logIn = new LoggerInputStream(srcInputStream, getLogger(), Level.WARN);
+    }
+    
+    @Test
+    public void read() throws Exception {
+        logIn.read();
+        assertMessages("before read int size", 0, "read");
+        logIn.read();
+        assertMessages("after read int size", 1, "read");
+
+        logIn.read(new byte[2]);
+        assertMessages("after read bytes size", 2, "read");
+
+        logIn.read(new byte[2], 0, 2);
+        assertMessages("after read bytes offset size", 3, "read");
+
+        logIn.read();
+        assertMessages("before close size", 3, "read");
+        logIn.close();
+        assertMessages("after close size", 4, "read");
+    }
+}

Propchange: logging/log4j/log4j2/trunk/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerInputStreamCallerInfoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message