001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.logging.log4j.io;
019
020 import java.io.BufferedInputStream;
021 import java.io.IOException;
022 import java.io.InputStream;
023 import java.nio.charset.Charset;
024
025 import org.apache.logging.log4j.Level;
026 import org.apache.logging.log4j.Marker;
027 import org.apache.logging.log4j.spi.ExtendedLogger;
028
029 /**
030 *
031 * @since 2.1
032 */
033 public class LoggerBufferedInputStream extends BufferedInputStream {
034 private static final String FQCN = LoggerBufferedInputStream.class.getName();
035
036 protected LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
037 final String fqcn, final Level level, final Marker marker) {
038 super(new LoggerInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker));
039 }
040
041 protected LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size,
042 final ExtendedLogger logger, final String fqcn, final Level level,
043 final Marker marker) {
044 super(new LoggerInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker), size);
045 }
046
047 @Override
048 public void close() throws IOException {
049 super.close();
050 }
051
052 @Override
053 public synchronized int read() throws IOException {
054 return super.read();
055 }
056
057 @Override
058 public int read(final byte[] b) throws IOException {
059 return super.read(b, 0, b.length);
060 }
061
062 @Override
063 public synchronized int read(final byte[] b, final int off, final int len) throws IOException {
064 return super.read(b, off, len);
065 }
066
067 @Override
068 public String toString() {
069 return LoggerBufferedInputStream.class.getSimpleName() + "{stream=" + this.in + '}';
070 }
071 }