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.internal;
019
020import java.io.PrintWriter;
021import java.io.Writer;
022import java.util.Locale;
023
024import org.apache.logging.log4j.Level;
025import org.apache.logging.log4j.Marker;
026import org.apache.logging.log4j.spi.ExtendedLogger;
027
028/**
029 * Internal class that exists primarly to allow location calculations to work.
030 *
031 * @since 2.12
032 */
033public class InternalPrintWriter extends PrintWriter {
034
035    public InternalPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
036                                final Level level, final Marker marker) {
037        super(new InternalWriter(logger, fqcn, level, marker), autoFlush);
038    }
039
040    public InternalPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
041                                final String fqcn, final Level level, final Marker marker) {
042        super(new InternalFilterWriter(writer, logger, fqcn, level, marker), autoFlush);
043    }
044
045    @Override
046    public InternalPrintWriter append(final char c) {
047        super.append(c);
048        return this;
049    }
050
051    @Override
052    public InternalPrintWriter append(final CharSequence csq) {
053        super.append(csq);
054        return this;
055    }
056
057    @Override
058    public InternalPrintWriter append(final CharSequence csq, final int start, final int end) {
059        super.append(csq, start, end);
060        return this;
061    }
062
063    @Override
064    public boolean checkError() {
065        return super.checkError();
066    }
067
068    @Override
069    public void close() {
070        super.close();
071    }
072
073    @Override
074    public void flush() {
075        super.flush();
076    }
077
078    @Override
079    public InternalPrintWriter format(final Locale l, final String format, final Object... args) {
080        super.format(l, format, args);
081        return this;
082    }
083
084    @Override
085    public InternalPrintWriter format(final String format, final Object... args) {
086        super.format(format, args);
087        return this;
088    }
089
090    @Override
091    public void print(final boolean b) {
092        super.print(b);
093    }
094
095    @Override
096    public void print(final char c) {
097        super.print(c);
098    }
099
100    @Override
101    public void print(final char[] s) {
102        super.print(s);
103    }
104
105    @Override
106    public void print(final double d) {
107        super.print(d);
108    }
109
110    @Override
111    public void print(final float f) {
112        super.print(f);
113    }
114
115    @Override
116    public void print(final int i) {
117        super.print(i);
118    }
119
120    @Override
121    public void print(final long l) {
122        super.print(l);
123    }
124
125    @Override
126    public void print(final Object obj) {
127        super.print(obj);
128    }
129
130    @Override
131    public void print(final String s) {
132        super.print(s);
133    }
134
135    @Override
136    public InternalPrintWriter printf(final Locale l, final String format, final Object... args) {
137        super.printf(l, format, args);
138        return this;
139    }
140
141    @Override
142    public InternalPrintWriter printf(final String format, final Object... args) {
143        super.printf(format, args);
144        return this;
145    }
146
147    @Override
148    public void println() {
149        super.println();
150    }
151
152    @Override
153    public void println(final boolean x) {
154        super.println(x);
155    }
156
157    @Override
158    public void println(final char x) {
159        super.println(x);
160    }
161
162    @Override
163    public void println(final char[] x) {
164        super.println(x);
165    }
166
167    @Override
168    public void println(final double x) {
169        super.println(x);
170    }
171
172    @Override
173    public void println(final float x) {
174        super.println(x);
175    }
176
177    @Override
178    public void println(final int x) {
179        super.println(x);
180    }
181
182    @Override
183    public void println(final long x) {
184        super.println(x);
185    }
186
187    @Override
188    public void println(final Object x) {
189        super.println(x);
190    }
191
192    @Override
193    public void println(final String x) {
194        super.println(x);
195    }
196
197    @Override
198    public String toString() {
199        return "{stream=" + this.out + '}';
200    }
201
202    @Override
203    public void write(final char[] buf) {
204        super.write(buf);
205    }
206
207    @Override
208    public void write(final char[] buf, final int off, final int len) {
209        super.write(buf, off, len);
210    }
211
212    @Override
213    public void write(final int c) {
214        super.write(c);
215    }
216
217    @Override
218    public void write(final String s) {
219        super.write(s);
220    }
221
222    @Override
223    public void write(final String s, final int off, final int len) {
224        super.write(s, off, len);
225    }
226}