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.io.LoggerFilterWriter;
27  import org.apache.logging.log4j.io.LoggerWriter;
28  import org.apache.logging.log4j.spi.ExtendedLogger;
29  
30  /**
31   * Internal class that exists primiarly to allow location calculations to work.
32   *
33   * @since 2.12
34   */
35  public class InternalPrintWriter extends PrintWriter {
36  
37      public InternalPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
38                                  final Level level, final Marker marker) {
39          super(new InternalWriter(logger, fqcn, level, marker), autoFlush);
40      }
41  
42      public InternalPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
43                                  final String fqcn, final Level level, final Marker marker) {
44          super(new InternalFilterWriter(writer, logger, fqcn, level, marker), autoFlush);
45      }
46  
47      @Override
48      public InternalPrintWriter append(final char c) {
49          super.append(c);
50          return this;
51      }
52  
53      @Override
54      public InternalPrintWriter append(final CharSequence csq) {
55          super.append(csq);
56          return this;
57      }
58  
59      @Override
60      public InternalPrintWriter append(final CharSequence csq, final int start, final int end) {
61          super.append(csq, start, end);
62          return this;
63      }
64  
65      @Override
66      public boolean checkError() {
67          return super.checkError();
68      }
69  
70      @Override
71      public void close() {
72          super.close();
73      }
74  
75      @Override
76      public void flush() {
77          super.flush();
78      }
79  
80      @Override
81      public InternalPrintWriter format(final Locale l, final String format, final Object... args) {
82          super.format(l, format, args);
83          return this;
84      }
85  
86      @Override
87      public InternalPrintWriter format(final String format, final Object... args) {
88          super.format(format, args);
89          return this;
90      }
91  
92      @Override
93      public void print(final boolean b) {
94          super.print(b);
95      }
96  
97      @Override
98      public void print(final char c) {
99          super.print(c);
100     }
101 
102     @Override
103     public void print(final char[] s) {
104         super.print(s);
105     }
106 
107     @Override
108     public void print(final double d) {
109         super.print(d);
110     }
111 
112     @Override
113     public void print(final float f) {
114         super.print(f);
115     }
116 
117     @Override
118     public void print(final int i) {
119         super.print(i);
120     }
121 
122     @Override
123     public void print(final long l) {
124         super.print(l);
125     }
126 
127     @Override
128     public void print(final Object obj) {
129         super.print(obj);
130     }
131 
132     @Override
133     public void print(final String s) {
134         super.print(s);
135     }
136 
137     @Override
138     public InternalPrintWriter printf(final Locale l, final String format, final Object... args) {
139         super.printf(l, format, args);
140         return this;
141     }
142 
143     @Override
144     public InternalPrintWriter printf(final String format, final Object... args) {
145         super.printf(format, args);
146         return this;
147     }
148 
149     @Override
150     public void println() {
151         super.println();
152     }
153 
154     @Override
155     public void println(final boolean x) {
156         super.println(x);
157     }
158 
159     @Override
160     public void println(final char x) {
161         super.println(x);
162     }
163 
164     @Override
165     public void println(final char[] x) {
166         super.println(x);
167     }
168 
169     @Override
170     public void println(final double x) {
171         super.println(x);
172     }
173 
174     @Override
175     public void println(final float x) {
176         super.println(x);
177     }
178 
179     @Override
180     public void println(final int x) {
181         super.println(x);
182     }
183 
184     @Override
185     public void println(final long x) {
186         super.println(x);
187     }
188 
189     @Override
190     public void println(final Object x) {
191         super.println(x);
192     }
193 
194     @Override
195     public void println(final String x) {
196         super.println(x);
197     }
198 
199     @Override
200     public String toString() {
201         return "{stream=" + this.out + '}';
202     }
203 
204     @Override
205     public void write(final char[] buf) {
206         super.write(buf);
207     }
208 
209     @Override
210     public void write(final char[] buf, final int off, final int len) {
211         super.write(buf, off, len);
212     }
213 
214     @Override
215     public void write(final int c) {
216         super.write(c);
217     }
218 
219     @Override
220     public void write(final String s) {
221         super.write(s);
222     }
223 
224     @Override
225     public void write(final String s, final int off, final int len) {
226         super.write(s, off, len);
227     }
228 }