1 package org.apache.velocity.tools.generic.log;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.velocity.app.Velocity;
23 import org.apache.velocity.runtime.log.Log;
24
25
26
27
28
29
30
31
32
33
34
35
36 public class LogChuteCommonsLog implements org.apache.commons.logging.Log
37 {
38
39 private static Log target = null;
40
41
42
43
44 protected static Log getVelocityLog()
45 {
46 return target;
47 }
48
49
50
51
52 public static void setVelocityLog(Log target)
53 {
54 LogChuteCommonsLog.target = target;
55 }
56
57
58
59
60 private String category;
61
62 public LogChuteCommonsLog()
63 {
64 this("");
65 }
66
67 public LogChuteCommonsLog(String category)
68 {
69 this.category = category + ": ";
70 }
71
72 protected Log getTarget()
73 {
74 if (target == null)
75 {
76 return Velocity.getLog();
77 }
78 else
79 {
80 return target;
81 }
82 }
83
84
85
86
87
88
89
90
91 public void trace(Object message)
92 {
93 getTarget().trace(category+message);
94 }
95
96
97
98
99
100 public void trace(Object message, Throwable t)
101 {
102 getTarget().trace(category+message, t);
103 }
104
105
106
107
108 public void debug(Object message)
109 {
110 getTarget().debug(category+message);
111 }
112
113
114
115
116 public void debug(Object message, Throwable t)
117 {
118 getTarget().debug(category+message, t);
119 }
120
121
122
123
124 public void info(Object message)
125 {
126 getTarget().info(category+message);
127 }
128
129
130
131
132 public void info(Object message, Throwable t)
133 {
134 getTarget().info(category+message, t);
135 }
136
137
138
139
140 public void warn(Object message)
141 {
142 getTarget().warn(category+message);
143 }
144
145
146
147
148 public void warn(Object message, Throwable t)
149 {
150 getTarget().warn(category+message, t);
151 }
152
153
154
155
156 public void error(Object message)
157 {
158 getTarget().error(category+message);
159 }
160
161
162
163
164 public void error(Object message, Throwable t)
165 {
166 getTarget().error(category+message, t);
167 }
168
169
170
171
172
173 public void fatal(Object message)
174 {
175 getTarget().error(category+message);
176 }
177
178
179
180
181
182 public void fatal(Object message, Throwable t)
183 {
184 getTarget().error(category+message, t);
185 }
186
187
188
189
190
191 public boolean isTraceEnabled()
192 {
193 return getTarget().isTraceEnabled();
194 }
195
196
197
198
199
200 public boolean isDebugEnabled()
201 {
202 return getTarget().isDebugEnabled();
203 }
204
205
206
207
208
209 public boolean isInfoEnabled()
210 {
211 return getTarget().isInfoEnabled();
212 }
213
214
215
216
217
218 public boolean isWarnEnabled()
219 {
220 return getTarget().isWarnEnabled();
221 }
222
223
224
225
226
227 public boolean isErrorEnabled()
228 {
229 return getTarget().isErrorEnabled();
230 }
231
232
233
234
235
236 public boolean isFatalEnabled()
237 {
238 return isErrorEnabled();
239 }
240
241 }