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 018package org.apache.logging.log4j.io; 019 020import java.io.BufferedReader; 021import java.io.IOException; 022import java.io.Reader; 023import java.nio.CharBuffer; 024 025import org.apache.logging.log4j.Level; 026import org.apache.logging.log4j.Marker; 027import org.apache.logging.log4j.io.internal.InternalBufferedReader; 028import org.apache.logging.log4j.spi.ExtendedLogger; 029 030/** 031 * 032 * @since 2.1 033 */ 034public class LoggerBufferedReader extends BufferedReader { 035 private static final String FQCN = LoggerBufferedReader.class.getName(); 036 private final InternalBufferedReader reader; 037 038 protected LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final String fqcn, 039 final Level level, final Marker marker) { 040 super(reader); 041 this.reader = new InternalBufferedReader(reader, logger, fqcn == null ? FQCN : fqcn, level, marker); 042 } 043 044 protected LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final String fqcn, 045 final Level level, final Marker marker) { 046 super(reader); 047 this.reader = new InternalBufferedReader(reader, size, logger, fqcn == null ? FQCN : fqcn, level, marker); 048 } 049 050 @Override 051 public void close() throws IOException { 052 reader.close(); 053 } 054 055 @Override 056 public int read() throws IOException { 057 return reader.read(); 058 } 059 060 @Override 061 public int read(final char[] cbuf) throws IOException { 062 return reader.read(cbuf); 063 } 064 065 @Override 066 public int read(final char[] cbuf, final int off, final int len) throws IOException { 067 return reader.read(cbuf, off, len); 068 } 069 070 @Override 071 public int read(final CharBuffer target) throws IOException { 072 return reader.read(target); 073 } 074 075 @Override 076 public String readLine() throws IOException { 077 return reader.readLine(); 078 } 079}