logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sicker <boa...@gmail.com>
Subject Re: git commit: Refactor LoggerOutputStream into two classes: LoggerOutputStream and LoggerFilterOutputStream. The old LoggerOutputStream is like the new LoggerFilterOutputStream which subclasses FilterOutputStream. The idea behind the new LoggerOutputStream
Date Wed, 03 Sep 2014 04:33:29 GMT
Kind of like the javadoc summaries. It's just a quick indexOf()-style
operation, though. Would be useful.


On 2 September 2014 23:00, Gary Gregory <garydgregory@gmail.com> wrote:

> Hmm... Or the git hook could be _smarter_ and parse out the first
> sentence, say up to the first period. Formatting comments is just a pain
> IMO.
>
> Gary
>
>
> On Tue, Sep 2, 2014 at 11:41 PM, Matt Sicker <boards@gmail.com> wrote:
>
>> This is why I make the first line of my commits really short. So it fits
>> in the email subject! Now that the git emails do this, it might be a good
>> habit to get into. ;)
>>
>> Commit style:
>>
>> Add some new thing.
>>
>>   - Some more details.
>>   - Doesn't really need to be a list like this, I'm just used to
>> changelogs joining them all together into a list.
>>
>> ---------- Forwarded message ----------
>> From: <ggregory@apache.org>
>> Date: 2 September 2014 22:14
>> Subject: git commit: Refactor LoggerOutputStream into two classes:
>> LoggerOutputStream and LoggerFilterOutputStream. The old LoggerOutputStream
>> is like the new LoggerFilterOutputStream which subclasses
>> FilterOutputStream. The idea behind the new LoggerOutputStream
>> To: commits@logging.apache.org
>>
>>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master be7fdb43f -> 00e5f5658
>>
>>
>> Refactor LoggerOutputStream into two classes: LoggerOutputStream and
>> LoggerFilterOutputStream. The old LoggerOutputStream is like the new
>> LoggerFilterOutputStream which subclasses FilterOutputStream. The idea
>> behind the new LoggerOutputStream is that it does not need to carry and
>> write to another wrapped OutputStream. This parallels the recent changes
>> to LoggerWriter with LoggerFilterWriter.
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/00e5f565
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/00e5f565
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/00e5f565
>>
>> Branch: refs/heads/master
>> Commit: 00e5f565820a49e100ff4eae64b59fe91c42eeba
>> Parents: be7fdb4
>> Author: Gary Gregory <garydgregory@gmail.com>
>> Authored: Tue Sep 2 23:13:57 2014 -0400
>> Committer: Gary Gregory <garydgregory@gmail.com>
>> Committed: Tue Sep 2 23:13:57 2014 -0400
>>
>> ----------------------------------------------------------------------
>>  .../streams/LoggerBufferedInputStream.java      |  36 +++----
>>  .../log4j/streams/LoggerBufferedReader.java     |  20 ++--
>>  .../log4j/streams/LoggerFilterOutputStream.java | 101 +++++++++++++++++++
>>  .../log4j/streams/LoggerFilterWriter.java       |  14 +--
>>  .../log4j/streams/LoggerInputStream.java        |  14 +--
>>  .../log4j/streams/LoggerOutputStream.java       |  60 ++---------
>>  .../log4j/streams/LoggerPrintStream.java        |  53 +++++-----
>>  .../log4j/streams/LoggerPrintWriter.java        |  12 +--
>>  .../logging/log4j/streams/LoggerReader.java     |  14 +--
>>  .../logging/log4j/streams/LoggerWriter.java     |  10 +-
>>  .../log4j/streams/AbstractLoggerWriterTest.java |   2 +-
>>  .../LoggerOutputStreamCallerInfoTest.java       |   2 +-
>>  .../log4j/streams/LoggerOutputStreamTest.java   |   4 +-
>>  .../LoggerPrintStreamCallerInfoTest.java        |   3 +-
>>  .../streams/LoggerStreamsCallerInfoTesting.java |   6 +-
>>  15 files changed, 213 insertions(+), 138 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
>> b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
>> index 90c7cea..c126dbb 100644
>> ---
>> a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
>> +++
>> b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
>> @@ -29,12 +29,16 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
>>  public class LoggerBufferedInputStream extends BufferedInputStream {
>>      private static final String FQCN =
>> LoggerBufferedInputStream.class.getName();
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger, final String fqcn, final Level level,
>> final Marker marker) {
>> -        super(new LoggerInputStream(in, charset, logger, fqcn, level,
>> marker));
>> +    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger, final Level level) {
>> +        this(in, charset, logger, FQCN, level, null);
>>      }
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final int size, final ExtendedLogger logger, final String fqcn,
>> final Level level, final Marker marker) {
>> -        super(new LoggerInputStream(in, charset, logger, fqcn, level,
>> marker), size);
>> +    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger, final Level level, final Marker
>> marker) {
>> +        this(in, charset, logger, FQCN, level, marker);
>> +    }
>> +
>> +    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger, final String fqcn, final Level level,
>> final Marker marker) {
>> +        super(new LoggerInputStream(in, charset, logger, fqcn, level,
>> marker));
>>      }
>>
>>      public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final int size, final ExtendedLogger logger, final Level level) {
>> @@ -45,20 +49,20 @@ public class LoggerBufferedInputStream extends
>> BufferedInputStream {
>>          this(in, charset, size, logger, FQCN, level, marker);
>>      }
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger, final Level level) {
>> -        this(in, charset, logger, FQCN, level, null);
>> +    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final int size, final ExtendedLogger logger, final String fqcn,
>> final Level level, final Marker marker) {
>> +        super(new LoggerInputStream(in, charset, logger, fqcn, level,
>> marker), size);
>>      }
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger, final Level level, final Marker
>> marker) {
>> -        this(in, charset, logger, FQCN, level, marker);
>> +    public LoggerBufferedInputStream(final InputStream in, final
>> ExtendedLogger logger, final Level level) {
>> +        this(in, logger, FQCN, level, null);
>>      }
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final
>> ExtendedLogger logger, final String fqcn, final Level level, final Marker
>> marker) {
>> -        this(in, Charset.defaultCharset(), logger, fqcn, level, marker);
>> +    public LoggerBufferedInputStream(final InputStream in, final
>> ExtendedLogger logger, final Level level, final Marker marker) {
>> +        this(in, logger, FQCN, level, marker);
>>      }
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final int
>> size, final ExtendedLogger logger, final String fqcn, final Level level,
>> final Marker marker) {
>> -        this(in, Charset.defaultCharset(), size, logger, fqcn, level,
>> marker);
>> +    public LoggerBufferedInputStream(final InputStream in, final
>> ExtendedLogger logger, final String fqcn, final Level level, final Marker
>> marker) {
>> +        this(in, Charset.defaultCharset(), logger, fqcn, level, marker);
>>      }
>>
>>      public LoggerBufferedInputStream(final InputStream in, final int
>> size, final ExtendedLogger logger, final Level level) {
>> @@ -68,13 +72,9 @@ public class LoggerBufferedInputStream extends
>> BufferedInputStream {
>>      public LoggerBufferedInputStream(final InputStream in, final int
>> size, final ExtendedLogger logger, final Level level, final Marker marker) {
>>          this(in, size, logger, FQCN, level, marker);
>>      }
>> -
>> -    public LoggerBufferedInputStream(final InputStream in, final
>> ExtendedLogger logger, final Level level) {
>> -        this(in, logger, FQCN, level, null);
>> -    }
>>
>> -    public LoggerBufferedInputStream(final InputStream in, final
>> ExtendedLogger logger, final Level level, final Marker marker) {
>> -        this(in, logger, FQCN, level, marker);
>> +    public LoggerBufferedInputStream(final InputStream in, final int
>> size, final ExtendedLogger logger, final String fqcn, final Level level,
>> final Marker marker) {
>> +        this(in, Charset.defaultCharset(), size, logger, fqcn, level,
>> marker);
>>      }
>>
>>      @Override
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
>> b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
>> index 2db1c8d..da770a7 100644
>> ---
>> a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
>> +++
>> b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
>> @@ -29,12 +29,16 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
>>  public class LoggerBufferedReader extends BufferedReader {
>>      private static final String FQCN =
>> LoggerBufferedReader.class.getName();
>>
>> -    public LoggerBufferedReader(final Reader reader, final
>> ExtendedLogger logger, final String fqcn, final Level level, final Marker
>> marker) {
>> -        super(new LoggerReader(reader, logger, FQCN, level, marker));
>> +    public LoggerBufferedReader(final Reader reader, final
>> ExtendedLogger logger, final Level level) {
>> +        this(reader, logger, FQCN, level, null);
>>      }
>>
>> -    public LoggerBufferedReader(final Reader reader, final int size,
>> final ExtendedLogger logger, final String fqcn, final Level level, final
>> Marker marker) {
>> -        super(new LoggerReader(reader, logger, FQCN, level, marker),
>> size);
>> +    public LoggerBufferedReader(final Reader reader, final
>> ExtendedLogger logger, final Level level, final Marker marker) {
>> +        this(reader, logger, FQCN, level, marker);
>> +    }
>> +
>> +    public LoggerBufferedReader(final Reader reader, final
>> ExtendedLogger logger, final String fqcn, final Level level, final Marker
>> marker) {
>> +        super(new LoggerReader(reader, logger, FQCN, level, marker));
>>      }
>>
>>      public LoggerBufferedReader(final Reader reader, final int size,
>> final ExtendedLogger logger, final Level level) {
>> @@ -45,12 +49,8 @@ public class LoggerBufferedReader extends
>> BufferedReader {
>>          this(reader, size, logger, FQCN, level, marker);
>>      }
>>
>> -    public LoggerBufferedReader(final Reader reader, final
>> ExtendedLogger logger, final Level level) {
>> -        this(reader, logger, FQCN, level, null);
>> -    }
>> -
>> -    public LoggerBufferedReader(final Reader reader, final
>> ExtendedLogger logger, final Level level, final Marker marker) {
>> -        this(reader, logger, FQCN, level, marker);
>> +    public LoggerBufferedReader(final Reader reader, final int size,
>> final ExtendedLogger logger, final String fqcn, final Level level, final
>> Marker marker) {
>> +        super(new LoggerReader(reader, logger, FQCN, level, marker),
>> size);
>>      }
>>
>>      @Override
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> new file mode 100644
>> index 0000000..96ab4e1
>> --- /dev/null
>> +++
>> b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerFilterOutputStream.java
>> @@ -0,0 +1,101 @@
>> +/*
>> + * 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/00e5f565/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
>> index 2735d89..2659c04 100644
>> ---
>> 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
>> @@ -36,13 +36,6 @@ public class LoggerFilterWriter extends FilterWriter {
>>      private final CharStreamLogger logger;
>>      private final String fqcn;
>>
>> -    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;
>> -    }
>> -
>>      public LoggerFilterWriter(final Writer out, final ExtendedLogger
>> logger, final Level level) {
>>          this(out, logger, FQCN, level, null);
>>      }
>> @@ -51,6 +44,13 @@ public class LoggerFilterWriter extends FilterWriter {
>>          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();
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index b4d242f..64eb202 100644
>> ---
>> 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
>> @@ -36,13 +36,6 @@ public class LoggerInputStream extends
>> FilterInputStream {
>>      private final String fqcn;
>>      private final ByteStreamLogger logger;
>>
>> -    public LoggerInputStream(final InputStream in, final Charset
>> charset, final ExtendedLogger logger,
>> -            final 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 Charset
>> charset, final ExtendedLogger logger, final Level level) {
>>          this(in, charset, logger, FQCN, level, null);
>>      }
>> @@ -52,6 +45,13 @@ public class LoggerInputStream extends
>> FilterInputStream {
>>          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);
>>      }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index c979432..836a20b 100644
>> ---
>> 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
>> @@ -35,91 +35,53 @@ import
>> org.apache.logging.log4j.streams.util.ByteStreamLogger;
>>  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 Charset charset, final
>> ExtendedLogger logger, final Level level) {
>> -        this(null, charset, logger, FQCN, level, null);
>> +    public LoggerOutputStream(final ExtendedLogger logger, final Level
>> level) {
>> +        this(logger, level, null, Charset.defaultCharset(), FQCN);
>>      }
>>
>> -    public LoggerOutputStream(final Charset charset, final
>> ExtendedLogger logger, final Level level, final Marker marker) {
>> -        this(null, charset, logger, FQCN, level, marker);
>> +    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) {
>> -        this(null, Charset.defaultCharset(), logger, FQCN, level, null);
>> +    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) {
>> -        this(null, Charset.defaultCharset(), logger, FQCN, level,
>> marker);
>> +    public LoggerOutputStream(final ExtendedLogger logger, final Level
>> level, final Marker marker, final Charset charset) {
>> +        this(logger, level, marker, charset, FQCN);
>>      }
>>
>> -    public LoggerOutputStream(final OutputStream out, final Charset
>> charset, final ExtendedLogger logger,
>> -            final String fqcn, final Level level, final Marker marker) {
>> -        this.out = out;
>> +    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;
>>      }
>>
>> -    public LoggerOutputStream(final OutputStream out, final Charset
>> charset, final ExtendedLogger logger, final Level level) {
>> -        this(out, charset, logger, FQCN, level, null);
>> -    }
>> -
>> -    public LoggerOutputStream(final OutputStream out, final Charset
>> charset, final ExtendedLogger logger, final Level level,
>> -            final Marker marker) {
>> -        this(out, charset, logger, FQCN, level, marker);
>> -    }
>> -
>> -    public LoggerOutputStream(final OutputStream out, final
>> ExtendedLogger logger, final Level level) {
>> -        this(out, Charset.defaultCharset(), logger, FQCN, level, null);
>> -    }
>> -
>> -    public LoggerOutputStream(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 {
>> -        if (this.out != null) {
>> -            this.out.close();
>> -        }
>>          this.logger.close(this.fqcn);
>>      }
>>
>>      @Override
>>      public void flush() throws IOException {
>> -        if (this.out != null) {
>> -            this.out.flush();
>> -        }
>> -    }
>> -
>> -    @Override
>> -    public String toString() {
>> -        return LoggerOutputStream.class.getSimpleName() + "{stream=" +
>> this.out + '}';
>> +        // do nothing
>>      }
>>
>>      @Override
>>      public void write(final byte[] b) throws IOException {
>> -        if (this.out != null) {
>> -            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 {
>> -        if (this.out != null) {
>> -            this.out.write(b, off, len);
>> -        }
>>          this.logger.put(this.fqcn, b, off, len);
>>      }
>>
>>      @Override
>>      public void write(final int b) throws IOException {
>> -        if (this.out != null) {
>> -            this.out.write(b);
>> -        }
>>          this.logger.put(this.fqcn, (byte) (b & 0xFF));
>>      }
>>  }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index a407b49..246fab5 100644
>> ---
>> 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
>> @@ -37,28 +37,28 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
>>  public class LoggerPrintStream extends PrintStream {
>>      private static final String FQCN = LoggerPrintStream.class.getName();
>>
>> -    public LoggerPrintStream(final Charset charset, final ExtendedLogger
>> logger, final Level level)
>> -            throws UnsupportedEncodingException {
>> -        this(null, false, charset, logger, FQCN, level, null);
>> +    public LoggerPrintStream(ExtendedLogger logger, boolean autoFlush,
>> Charset charset, String fqcn, Level level,
>> +            Marker marker) throws UnsupportedEncodingException {
>> +        super(new LoggerOutputStream(logger, level, marker, charset,
>> fqcn), autoFlush, charset.name());
>>      }
>>
>> -    public LoggerPrintStream(final Charset charset, final ExtendedLogger
>> logger, final Level level, final Marker marker)
>> -            throws UnsupportedEncodingException {
>> -        this(null, false, charset, logger, FQCN, level, marker);
>> +    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) {
>> -        this(null, false, logger, 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) {
>> -        this(null, false, logger, FQCN, level, marker);
>> +    public LoggerPrintStream(final ExtendedLogger logger, final Level
>> level, final Marker marker)
>> +            throws UnsupportedEncodingException {
>> +        this(logger, false, Charset.defaultCharset(), 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)
>> +    public LoggerPrintStream(final ExtendedLogger logger, final Level
>> level, final Marker marker, final Charset charset)
>>              throws UnsupportedEncodingException {
>> -        super(new LoggerOutputStream(out, charset, logger, fqcn, level,
>> marker), autoFlush, charset.name());
>> +        this(logger, false, charset, FQCN, level, marker);
>>      }
>>
>>      public LoggerPrintStream(final OutputStream out, final boolean
>> autoFlush, final Charset charset,
>> @@ -71,27 +71,34 @@ public class LoggerPrintStream extends PrintStream {
>>          this(out, autoFlush, charset, 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 LoggerOutputStream(out, Charset.defaultCharset(),
>> logger, fqcn, level, marker), autoFlush);
>> +    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) {
>> +    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) {
>> +    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 Charset
>> charset, final ExtendedLogger logger, final Level level)
>> -            throws UnsupportedEncodingException {
>> +    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 {
>> +    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);
>>      }
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index 2a6b02a..e5cdf98 100644
>> ---
>> 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
>> @@ -51,12 +51,6 @@ public class LoggerPrintWriter extends PrintWriter {
>>          this(logger, false, 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 boolean
>> autoFlush, final ExtendedLogger logger, final Level level) {
>>          this(writer, autoFlush, logger, FQCN, level, null);
>>      }
>> @@ -66,6 +60,12 @@ public class LoggerPrintWriter extends PrintWriter {
>>          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);
>>      }
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index 33a36de..5e7ccd8 100644
>> ---
>> 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
>> @@ -37,13 +37,6 @@ public class LoggerReader extends FilterReader {
>>      private final CharStreamLogger logger;
>>      private final String fqcn;
>>
>> -    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;
>> -    }
>> -
>>      public LoggerReader(final Reader reader, final ExtendedLogger
>> logger, final Level level) {
>>          this(reader, logger, FQCN, level, null);
>>      }
>> @@ -52,6 +45,13 @@ public class LoggerReader extends FilterReader {
>>          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();
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index 53d9324..68fdc83 100644
>> ---
>> 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
>> @@ -35,11 +35,6 @@ public class LoggerWriter extends Writer {
>>      private final CharStreamLogger logger;
>>      private final String fqcn;
>>
>> -    public LoggerWriter(final ExtendedLogger logger, final String fqcn,
>> final Level level, final Marker marker) {
>> -        this.logger = new CharStreamLogger(logger, level, marker);
>> -        this.fqcn = fqcn;
>> -    }
>> -
>>      public LoggerWriter(final ExtendedLogger logger, final Level level) {
>>          this(logger, FQCN, level, null);
>>      }
>> @@ -48,6 +43,11 @@ public class LoggerWriter extends Writer {
>>          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);
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/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
>> index 78b13fd..7b19495 100644
>> ---
>> 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
>> @@ -70,7 +70,7 @@ public abstract class AbstractLoggerWriterTest extends
>> AbstractStreamTest {
>>          out.close();
>>          replay(out);
>>
>> -        final LoggerOutputStream los = new LoggerOutputStream(out,
>> getExtendedLogger(), LEVEL);
>> +        final LoggerFilterOutputStream los = new
>> LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
>>          los.flush();
>>          los.close();
>>          verify(out);
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamCallerInfoTest.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamCallerInfoTest.java
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamCallerInfoTest.java
>> index 3a38753..73fb966 100644
>> ---
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamCallerInfoTest.java
>> +++
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamCallerInfoTest.java
>> @@ -26,7 +26,7 @@ public class LoggerOutputStreamCallerInfoTest extends
>> LoggerStreamsCallerInfoTes
>>
>>      @Before
>>      public void setupStreams() {
>> -        this.logOut = new LoggerOutputStream(getLogger(), Level.WARN);
>> +        this.logOut = new LoggerOutputStream(getExtendedLogger(),
>> Level.WARN);
>>      }
>>
>>      @Test
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamTest.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamTest.java
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamTest.java
>> index 115d57e..e6450ee 100644
>> ---
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamTest.java
>> +++
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerOutputStreamTest.java
>> @@ -34,7 +34,7 @@ public class LoggerOutputStreamTest extends
>> AbstractStreamTest {
>>      protected OutputStream out;
>>
>>      protected OutputStream createOutputStream() {
>> -        return new LoggerOutputStream(this.wrapped, getExtendedLogger(),
>> Level.ERROR);
>> +        return new LoggerFilterOutputStream(this.wrapped,
>> getExtendedLogger(), Level.ERROR);
>>      }
>>
>>      @Before
>> @@ -66,7 +66,7 @@ public class LoggerOutputStreamTest extends
>> AbstractStreamTest {
>>          out.close();
>>          replay(out);
>>
>> -        final LoggerOutputStream los = new LoggerOutputStream(out,
>> getExtendedLogger(), LEVEL);
>> +        final LoggerFilterOutputStream los = new
>> LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
>>          los.flush();
>>          los.close();
>>          verify(out);
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamCallerInfoTest.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamCallerInfoTest.java
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamCallerInfoTest.java
>> index 21d8b58..ad6aeda 100644
>> ---
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamCallerInfoTest.java
>> +++
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerPrintStreamCallerInfoTest.java
>> @@ -16,6 +16,7 @@
>>   */
>>  package org.apache.logging.log4j.streams;
>>
>> +import java.io.UnsupportedEncodingException;
>>  import java.util.Locale;
>>
>>  import org.apache.logging.log4j.Level;
>> @@ -119,7 +120,7 @@ public class LoggerPrintStreamCallerInfoTest extends
>> LoggerStreamsCallerInfoTest
>>      }
>>
>>      @Before
>> -    public void setupStreams() {
>> +    public void setupStreams() throws UnsupportedEncodingException {
>>          this.logOut = new LoggerPrintStream(getLogger(), Level.WARN);
>>      }
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/00e5f565/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerStreamsCallerInfoTesting.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerStreamsCallerInfoTesting.java
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerStreamsCallerInfoTesting.java
>> index 73f22a0..0af5a30 100644
>> ---
>> a/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerStreamsCallerInfoTesting.java
>> +++
>> b/log4j-streams/src/test/java/org/apache/logging/log4j/streams/LoggerStreamsCallerInfoTesting.java
>> @@ -27,10 +27,14 @@ import org.junit.ClassRule;
>>
>>  public class LoggerStreamsCallerInfoTesting {
>>
>> -    protected static Logger getLogger() {
>> +    protected static Logger getExtendedLogger() {
>>          return ctx.getLogger("ClassAndMethodLogger");
>>      }
>>
>> +    protected static Logger getLogger() {
>> +        return getExtendedLogger();
>> +    }
>> +
>>      protected final static Level LEVEL = Level.WARN;
>>
>>      @ClassRule
>>
>>
>>
>>
>> --
>> Matt Sicker <boards@gmail.com>
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <boards@gmail.com>

Mime
View raw message