1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.logging.log4j.io.internal;
19
20 import java.io.IOException;
21 import java.io.Writer;
22
23 import org.apache.logging.log4j.Level;
24 import org.apache.logging.log4j.Marker;
25 import org.apache.logging.log4j.io.CharStreamLogger;
26 import org.apache.logging.log4j.spi.ExtendedLogger;
27
28
29
30
31
32 public class InternalWriter extends Writer {
33
34 private final CharStreamLogger logger;
35 private final String fqcn;
36
37 public InternalWriter(final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
38 this.logger = new CharStreamLogger(logger, level, marker);
39 this.fqcn = fqcn;
40 }
41
42 @Override
43 public void close() throws IOException {
44 this.logger.close(this.fqcn);
45 }
46
47 @Override
48 public void flush() throws IOException {
49
50 }
51
52 @Override
53 public String toString() {
54 return this.getClass().getSimpleName() + "[fqcn=" + this.fqcn + ", logger=" + this.logger + "]";
55 }
56
57 @Override
58 public void write(final char[] cbuf) throws IOException {
59 this.logger.put(this.fqcn, cbuf, 0, cbuf.length);
60 }
61
62 @Override
63 public void write(final char[] cbuf, final int off, final int len) throws IOException {
64 this.logger.put(this.fqcn, cbuf, off, len);
65 }
66
67 @Override
68 public void write(final int c) throws IOException {
69 this.logger.put(this.fqcn, (char) c);
70 }
71
72 @Override
73 public void write(final String str) throws IOException {
74 this.logger.put(this.fqcn, str, 0, str.length());
75 }
76
77 @Override
78 public void write(final String str, final int off, final int len) throws IOException {
79 this.logger.put(this.fqcn, str, off, len);
80 }
81 }