1 | /** |
---|
2 | * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface. |
---|
3 | * Copyright (C) 2012 Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior |
---|
4 | * |
---|
5 | * This program is free software: you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU Affero General Public License as |
---|
7 | * published by the Free Software Foundation, either version 3 of the |
---|
8 | * License, or (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU Affero General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU Affero General Public License |
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | */ |
---|
18 | |
---|
19 | /******************************************************************************\ |
---|
20 | * |
---|
21 | * This product was developed by |
---|
22 | * |
---|
23 | * SERVIÃO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), |
---|
24 | * |
---|
25 | * a government company established under Brazilian law (5.615/70), |
---|
26 | * at Department of Development of Porto Alegre. |
---|
27 | * |
---|
28 | \******************************************************************************/ |
---|
29 | |
---|
30 | package serpro.mailarchiver.util; |
---|
31 | |
---|
32 | import com.google.common.base.Supplier; |
---|
33 | import org.apache.log4j.Level; |
---|
34 | import org.apache.log4j.spi.LoggerFactory; |
---|
35 | |
---|
36 | public class Logger extends org.apache.log4j.Logger { |
---|
37 | |
---|
38 | protected Logger(String name) { |
---|
39 | super(name); |
---|
40 | } |
---|
41 | |
---|
42 | public static Logger getLocalLogger() { |
---|
43 | return (Logger) org.apache.log4j.Logger.getLogger( |
---|
44 | Thread.currentThread().getStackTrace()[2].getClassName(), |
---|
45 | new LoggerFactory() { |
---|
46 | @Override |
---|
47 | public org.apache.log4j.Logger makeNewLoggerInstance(String string) { |
---|
48 | return new Logger(string); |
---|
49 | } |
---|
50 | } |
---|
51 | ); |
---|
52 | } |
---|
53 | |
---|
54 | //========================================================================== |
---|
55 | public void fatal(String message) { |
---|
56 | super.fatal(message); |
---|
57 | } |
---|
58 | |
---|
59 | public void fatal(String format, Object... args) { |
---|
60 | if(isEnabledFor(Level.FATAL)) { |
---|
61 | super.fatal(String.format(format, args)); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | public void fatal(String format, Supplier<Object[]> args) { |
---|
66 | if(isEnabledFor(Level.FATAL)) { |
---|
67 | super.fatal(String.format(format, args.get())); |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | public void fatal(Throwable t, String message) { |
---|
72 | super.fatal(message, t); |
---|
73 | } |
---|
74 | |
---|
75 | public void fatal(Throwable t, String format, Object... args) { |
---|
76 | if(isEnabledFor(Level.FATAL)) { |
---|
77 | super.fatal(String.format(format, args), t); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | public void fatal(Throwable t, String format, Supplier<Object[]> args) { |
---|
82 | if(isEnabledFor(Level.FATAL)) { |
---|
83 | super.fatal(String.format(format, args.get()), t); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | //========================================================================== |
---|
88 | public void error(String message) { |
---|
89 | super.error(message); |
---|
90 | } |
---|
91 | |
---|
92 | public void error(String format, Object... args) { |
---|
93 | if(isEnabledFor(Level.ERROR)) { |
---|
94 | super.error(String.format(format, args)); |
---|
95 | } |
---|
96 | } |
---|
97 | |
---|
98 | public void error(String format, Supplier<Object[]> args) { |
---|
99 | if(isEnabledFor(Level.ERROR)) { |
---|
100 | super.error(String.format(format, args.get())); |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | public void error(Throwable t, String message) { |
---|
105 | super.error(message, t); |
---|
106 | } |
---|
107 | |
---|
108 | public void error(Throwable t, String format, Object... args) { |
---|
109 | if(isEnabledFor(Level.ERROR)) { |
---|
110 | super.error(String.format(format, args), t); |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | public void error(Throwable t, String format, Supplier<Object[]> args) { |
---|
115 | if(isEnabledFor(Level.ERROR)) { |
---|
116 | super.error(String.format(format, args.get()), t); |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | //========================================================================== |
---|
121 | public void warn(String message) { |
---|
122 | super.warn(message); |
---|
123 | } |
---|
124 | |
---|
125 | public void warn(String format, Object... args) { |
---|
126 | if(isEnabledFor(Level.WARN)) { |
---|
127 | super.warn(String.format(format, args)); |
---|
128 | } |
---|
129 | } |
---|
130 | |
---|
131 | public void warn(String format, Supplier<Object[]> args) { |
---|
132 | if(isEnabledFor(Level.WARN)) { |
---|
133 | super.warn(String.format(format, args.get())); |
---|
134 | } |
---|
135 | } |
---|
136 | |
---|
137 | public void warn(Throwable t, String message) { |
---|
138 | super.warn(message, t); |
---|
139 | } |
---|
140 | |
---|
141 | public void warn(Throwable t, String format, Object... args) { |
---|
142 | if(isEnabledFor(Level.WARN)) { |
---|
143 | super.warn(String.format(format, args), t); |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | public void warn(Throwable t, String format, Supplier<Object[]> args) { |
---|
148 | if(isEnabledFor(Level.WARN)) { |
---|
149 | super.warn(String.format(format, args.get()), t); |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|
153 | //========================================================================== |
---|
154 | public void info(String message) { |
---|
155 | super.info(message); |
---|
156 | } |
---|
157 | |
---|
158 | public void info(String format, Object... args) { |
---|
159 | if(isEnabledFor(Level.INFO)) { |
---|
160 | super.info(String.format(format, args)); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | public void info(String format, Supplier<Object[]> args) { |
---|
165 | if(isEnabledFor(Level.INFO)) { |
---|
166 | super.info(String.format(format, args.get())); |
---|
167 | } |
---|
168 | } |
---|
169 | |
---|
170 | public void info(Throwable t, String message) { |
---|
171 | super.info(message, t); |
---|
172 | } |
---|
173 | |
---|
174 | public void info(Throwable t, String format, Object... args) { |
---|
175 | if(isEnabledFor(Level.INFO)) { |
---|
176 | super.info(String.format(format, args), t); |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | public void info(Throwable t, String format, Supplier<Object[]> args) { |
---|
181 | if(isEnabledFor(Level.INFO)) { |
---|
182 | super.info(String.format(format, args.get()), t); |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | //========================================================================== |
---|
187 | public void debug(String message) { |
---|
188 | super.debug(message); |
---|
189 | } |
---|
190 | |
---|
191 | public void debug(String format, Object... args) { |
---|
192 | if(isEnabledFor(Level.DEBUG)) { |
---|
193 | super.debug(String.format(format, args)); |
---|
194 | } |
---|
195 | } |
---|
196 | |
---|
197 | public void debug(String format, Supplier<Object[]> args) { |
---|
198 | if(isEnabledFor(Level.DEBUG)) { |
---|
199 | super.debug(String.format(format, args.get())); |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | public void debug(Throwable t, String message) { |
---|
204 | super.debug(message, t); |
---|
205 | } |
---|
206 | |
---|
207 | public void debug(Throwable t, String format, Object... args) { |
---|
208 | if(isEnabledFor(Level.DEBUG)) { |
---|
209 | super.debug(String.format(format, args), t); |
---|
210 | } |
---|
211 | } |
---|
212 | |
---|
213 | public void debug(Throwable t, String format, Supplier<Object[]> args) { |
---|
214 | if(isEnabledFor(Level.DEBUG)) { |
---|
215 | super.debug(String.format(format, args.get()), t); |
---|
216 | } |
---|
217 | } |
---|
218 | |
---|
219 | //========================================================================== |
---|
220 | public void trace(String message) { |
---|
221 | super.trace(message); |
---|
222 | } |
---|
223 | |
---|
224 | public void trace(String format, Object... args) { |
---|
225 | if(isEnabledFor(Level.TRACE)) { |
---|
226 | super.trace(String.format(format, args)); |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | public void trace(String format, Supplier<Object[]> args) { |
---|
231 | if(isEnabledFor(Level.TRACE)) { |
---|
232 | super.trace(String.format(format, args.get())); |
---|
233 | } |
---|
234 | } |
---|
235 | |
---|
236 | public void trace(Throwable t, String message) { |
---|
237 | super.trace(message, t); |
---|
238 | } |
---|
239 | |
---|
240 | public void trace(Throwable t, String format, Object... args) { |
---|
241 | if(isEnabledFor(Level.TRACE)) { |
---|
242 | super.trace(String.format(format, args), t); |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | public void trace(Throwable t, String format, Supplier<Object[]> args) { |
---|
247 | if(isEnabledFor(Level.TRACE)) { |
---|
248 | super.trace(String.format(format, args.get()), t); |
---|
249 | } |
---|
250 | } |
---|
251 | } |
---|