1 package org.apache.velocity.runtime.log;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 public class LogDisplayWrapper
33 extends Log
34 {
35
36 private final String prefix;
37
38
39 private final boolean outputMessages;
40
41
42 private final Log log;
43
44
45
46
47
48
49
50 public LogDisplayWrapper(final Log log, final String prefix, final boolean outputMessages)
51 {
52 super(log.getLogChute());
53 this.log = log;
54 this.prefix = prefix;
55 this.outputMessages = outputMessages;
56 }
57
58
59
60
61 protected LogChute getLogChute()
62 {
63 return log.getLogChute();
64 }
65
66
67
68
69 protected void log(final int level, final Object message)
70 {
71 log(outputMessages, level, message);
72 }
73
74 protected void log(final boolean doLogging, final int level, final Object message)
75 {
76 if (doLogging)
77 {
78 getLogChute().log(level, prefix + String.valueOf(message));
79 }
80 }
81
82
83
84
85 protected void log(final int level, final Object message, final Throwable t)
86 {
87 log(outputMessages, level, message);
88 }
89
90 protected void log(final boolean doLogging, final int level, final Object message, final Throwable t)
91 {
92 if (doLogging)
93 {
94 getLogChute().log(level, prefix + String.valueOf(message), t);
95 }
96 }
97
98
99
100
101
102
103 public void trace(final boolean doLogging, final Object message)
104 {
105 log(doLogging, LogChute.TRACE_ID, message);
106 }
107
108
109
110
111
112
113
114 public void trace(final boolean doLogging, final Object message, final Throwable t)
115 {
116 log(doLogging, LogChute.TRACE_ID, message, t);
117 }
118
119
120
121
122
123
124 public void debug(final boolean doLogging, final Object message)
125 {
126 log(doLogging, LogChute.DEBUG_ID, message);
127 }
128
129
130
131
132
133
134
135 public void debug(final boolean doLogging, final Object message, final Throwable t)
136 {
137 log(doLogging, LogChute.DEBUG_ID, message, t);
138 }
139
140
141
142
143
144
145 public void info(final boolean doLogging, final Object message)
146 {
147 log(doLogging, LogChute.INFO_ID, message);
148 }
149
150
151
152
153
154
155
156 public void info(final boolean doLogging, final Object message, final Throwable t)
157 {
158 log(doLogging, LogChute.INFO_ID, message, t);
159 }
160
161
162
163
164
165
166 public void warn(final boolean doLogging, final Object message)
167 {
168 log(doLogging, LogChute.WARN_ID, message);
169 }
170
171
172
173
174
175
176
177 public void warn(final boolean doLogging, final Object message, final Throwable t)
178 {
179 log(doLogging, LogChute.WARN_ID, message, t);
180 }
181
182
183
184
185
186
187 public void error(final boolean doLogging, final Object message)
188 {
189 log(doLogging, LogChute.ERROR_ID, message);
190 }
191
192
193
194
195
196
197
198 public void error(final boolean doLogging, final Object message, final Throwable t)
199 {
200 log(doLogging, LogChute.ERROR_ID, message, t);
201 }
202 }
203