View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.logging.log4j.io.internal;
19  
20  import java.io.PrintWriter;
21  import java.io.Writer;
22  import java.util.Locale;
23  
24  import org.apache.logging.log4j.Level;
25  import org.apache.logging.log4j.Marker;
26  import org.apache.logging.log4j.spi.ExtendedLogger;
27  
28  /**
29   * Internal class that exists primarly to allow location calculations to work.
30   *
31   * @since 2.12
32   */
33  public class InternalPrintWriter extends PrintWriter {
34  
35      public InternalPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
36                                  final Level level, final Marker marker) {
37          super(new InternalWriter(logger, fqcn, level, marker), autoFlush);
38      }
39  
40      public InternalPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
41                                  final String fqcn, final Level level, final Marker marker) {
42          super(new InternalFilterWriter(writer, logger, fqcn, level, marker), autoFlush);
43      }
44  
45      @Override
46      public InternalPrintWriter append(final char c) {
47          super.append(c);
48          return this;
49      }
50  
51      @Override
52      public InternalPrintWriter append(final CharSequence csq) {
53          super.append(csq);
54          return this;
55      }
56  
57      @Override
58      public InternalPrintWriter append(final CharSequence csq, final int start, final int end) {
59          super.append(csq, start, end);
60          return this;
61      }
62  
63      @Override
64      public boolean checkError() {
65          return super.checkError();
66      }
67  
68      @Override
69      public void close() {
70          super.close();
71      }
72  
73      @Override
74      public void flush() {
75          super.flush();
76      }
77  
78      @Override
79      public InternalPrintWriter format(final Locale l, final String format, final Object... args) {
80          super.format(l, format, args);
81          return this;
82      }
83  
84      @Override
85      public InternalPrintWriter format(final String format, final Object... args) {
86          super.format(format, args);
87          return this;
88      }
89  
90      @Override
91      public void print(final boolean b) {
92          super.print(b);
93      }
94  
95      @Override
96      public void print(final char c) {
97          super.print(c);
98      }
99  
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 }