Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractLog |
|
| 1.0;1 |
1 | /* | |
2 | * #%L | |
3 | * AbstractLog.java - mongodb-async-driver - Allanbank Consulting, Inc. | |
4 | * %% | |
5 | * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc. | |
6 | * %% | |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | * you may not use this file except in compliance with the License. | |
9 | * You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, software | |
14 | * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | * See the License for the specific language governing permissions and | |
17 | * limitations under the License. | |
18 | * #L% | |
19 | */ | |
20 | package com.allanbank.mongodb.util.log; | |
21 | ||
22 | import java.util.logging.Level; | |
23 | ||
24 | /** | |
25 | * AbstractLog implements all of the public log method to delegate to a single | |
26 | * {@link #doLog(Level, Throwable, String, Object...)} method. | |
27 | * | |
28 | * @api.no This class is <b>NOT</b> part of the drivers API. This class may be | |
29 | * mutated in incompatible ways between any two releases of the driver. | |
30 | * @copyright 2014, Allanbank Consulting, Inc., All Rights Reserved | |
31 | */ | |
32 | public abstract class AbstractLog implements Log { | |
33 | ||
34 | /** The name of this class. */ | |
35 | 1 | protected static final Object CLASS_NAME = AbstractLog.class.getName(); |
36 | ||
37 | /** | |
38 | * Creates a new AbstractLog. | |
39 | */ | |
40 | /* package */AbstractLog() { | |
41 | 265 | super(); |
42 | 265 | } |
43 | ||
44 | /** | |
45 | * {@inheritDoc} | |
46 | * <p> | |
47 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
48 | * </p> | |
49 | * | |
50 | * @see Log#debug(String) | |
51 | */ | |
52 | @Override | |
53 | public final void debug(final String message) { | |
54 | 43 | doLog(Level.FINE, (Throwable) null, message); |
55 | 43 | } |
56 | ||
57 | /** | |
58 | * {@inheritDoc} | |
59 | * <p> | |
60 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
61 | * </p> | |
62 | * | |
63 | * @see Log#debug(String, Object[]) | |
64 | */ | |
65 | @Override | |
66 | public final void debug(final String template, final Object... args) { | |
67 | 180 | doLog(Level.FINE, null, template, args); |
68 | 180 | } |
69 | ||
70 | /** | |
71 | * {@inheritDoc} | |
72 | * <p> | |
73 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
74 | * </p> | |
75 | * | |
76 | * @see Log#debug(Throwable, String, Object[]) | |
77 | */ | |
78 | @Override | |
79 | public final void debug(final Throwable thrown, final String template, | |
80 | final Object... args) { | |
81 | 8 | doLog(Level.FINE, thrown, template, args); |
82 | 8 | } |
83 | ||
84 | /** | |
85 | * {@inheritDoc} | |
86 | * <p> | |
87 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
88 | * </p> | |
89 | * | |
90 | * @see Log#error(String) | |
91 | */ | |
92 | @Override | |
93 | public final void error(final String message) { | |
94 | 4 | doLog(Level.SEVERE, (Throwable) null, message); |
95 | 4 | } |
96 | ||
97 | /** | |
98 | * {@inheritDoc} | |
99 | * <p> | |
100 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
101 | * </p> | |
102 | * | |
103 | * @see Log#error(String, Object[]) | |
104 | */ | |
105 | @Override | |
106 | public final void error(final String template, final Object... args) { | |
107 | 4 | doLog(Level.SEVERE, null, template, args); |
108 | 4 | } |
109 | ||
110 | /** | |
111 | * {@inheritDoc} | |
112 | * <p> | |
113 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
114 | * </p> | |
115 | * | |
116 | * @see Log#error(Throwable, String, Object[]) | |
117 | */ | |
118 | @Override | |
119 | public final void error(final Throwable thrown, final String template, | |
120 | final Object... args) { | |
121 | 5 | doLog(Level.SEVERE, thrown, template, args); |
122 | 5 | } |
123 | ||
124 | /** | |
125 | * {@inheritDoc} | |
126 | * <p> | |
127 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
128 | * </p> | |
129 | * | |
130 | * @see Log#info(String) | |
131 | */ | |
132 | @Override | |
133 | public final void info(final String message) { | |
134 | 51 | doLog(Level.INFO, (Throwable) null, message); |
135 | 51 | } |
136 | ||
137 | /** | |
138 | * {@inheritDoc} | |
139 | * <p> | |
140 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
141 | * </p> | |
142 | * | |
143 | * @see Log#info(String, Object[]) | |
144 | */ | |
145 | @Override | |
146 | public final void info(final String template, final Object... args) { | |
147 | 54 | doLog(Level.INFO, null, template, args); |
148 | 54 | } |
149 | ||
150 | /** | |
151 | * {@inheritDoc} | |
152 | * <p> | |
153 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
154 | * </p> | |
155 | * | |
156 | * @see Log#info(Throwable, String, Object[]) | |
157 | */ | |
158 | @Override | |
159 | public final void info(final Throwable thrown, final String template, | |
160 | final Object... args) { | |
161 | 4 | doLog(Level.INFO, thrown, template, args); |
162 | 4 | } |
163 | ||
164 | /** | |
165 | * {@inheritDoc} | |
166 | * <p> | |
167 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
168 | * </p> | |
169 | * | |
170 | * @see Log#log(Level, String) | |
171 | */ | |
172 | @Override | |
173 | public final void log(final Level level, final String message) { | |
174 | 5 | doLog(level, (Throwable) null, message); |
175 | 5 | } |
176 | ||
177 | /** | |
178 | * {@inheritDoc} | |
179 | * <p> | |
180 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
181 | * </p> | |
182 | * | |
183 | * @see Log#log(Level, String, Object[]) | |
184 | */ | |
185 | @Override | |
186 | public final void log(final Level level, final String template, | |
187 | final Object... args) { | |
188 | 1 | doLog(level, null, template, args); |
189 | 1 | } |
190 | ||
191 | /** | |
192 | * {@inheritDoc} | |
193 | * <p> | |
194 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
195 | * </p> | |
196 | * | |
197 | * @see Log#log(Level, Throwable, String, Object[]) | |
198 | */ | |
199 | @Override | |
200 | public final void log(final Level level, final Throwable thrown, | |
201 | final String template, final Object... args) { | |
202 | 0 | doLog(level, thrown, template, args); |
203 | 0 | } |
204 | ||
205 | /** | |
206 | * {@inheritDoc} | |
207 | * <p> | |
208 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
209 | * </p> | |
210 | * | |
211 | * @see Log#warn(String) | |
212 | */ | |
213 | @Override | |
214 | public final void warn(final String message) { | |
215 | 7 | doLog(Level.WARNING, (Throwable) null, message); |
216 | 7 | } |
217 | ||
218 | /** | |
219 | * {@inheritDoc} | |
220 | * <p> | |
221 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
222 | * </p> | |
223 | * | |
224 | * @see Log#warn(String, Object[]) | |
225 | */ | |
226 | @Override | |
227 | public final void warn(final String template, final Object... args) { | |
228 | 11 | doLog(Level.WARNING, null, template, args); |
229 | 11 | } |
230 | ||
231 | /** | |
232 | * {@inheritDoc} | |
233 | * <p> | |
234 | * Overridden to call {@link #doLog(Level, Throwable, String, Object...)}. | |
235 | * </p> | |
236 | * | |
237 | * @see Log#warn(Throwable, String, Object[]) | |
238 | */ | |
239 | @Override | |
240 | public final void warn(final Throwable thrown, final String template, | |
241 | final Object... args) { | |
242 | 52 | doLog(Level.WARNING, thrown, template, args); |
243 | 52 | } |
244 | ||
245 | /** | |
246 | * Delegate method for the {@link Log} implementation. | |
247 | * | |
248 | * @param level | |
249 | * The logging level for the message. | |
250 | * @param thrown | |
251 | * The exception associated with the log message. | |
252 | * @param template | |
253 | * The message template to log. | |
254 | * @param args | |
255 | * The arguments to replace the <code>{}</code> entries in the | |
256 | * template. | |
257 | */ | |
258 | protected abstract void doLog(Level level, Throwable thrown, | |
259 | String template, Object... args); | |
260 | ||
261 | } |