1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hiveutils.service.impl; |
16 | |
17 | import org.apache.commons.logging.Log; |
18 | import org.apache.commons.logging.impl.NoOpLog; |
19 | |
20 | public class LogWrapper extends NoOpLog |
21 | { |
22 | public LogWrapper(Log logger, LoggingLevel level) |
23 | { |
24 | _logger = logger; |
25 | _level = level; |
26 | } |
27 | |
28 | public void debug(Object message) |
29 | { |
30 | switch (_level) |
31 | { |
32 | case Error: |
33 | _logger.error(message); |
34 | break; |
35 | |
36 | case Warn: |
37 | _logger.warn(message); |
38 | break; |
39 | |
40 | case Info: |
41 | _logger.info(message); |
42 | break; |
43 | |
44 | case Debug: |
45 | _logger.debug(message); |
46 | break; |
47 | |
48 | case None: |
49 | default: |
50 | break; |
51 | } |
52 | } |
53 | |
54 | public void debug(Object message, Throwable t) |
55 | { |
56 | switch (_level) |
57 | { |
58 | case Error: |
59 | _logger.error(message, t); |
60 | break; |
61 | |
62 | case Warn: |
63 | _logger.warn(message, t); |
64 | break; |
65 | |
66 | case Info: |
67 | _logger.info(message, t); |
68 | break; |
69 | |
70 | case Debug: |
71 | _logger.debug(message, t); |
72 | break; |
73 | |
74 | case None: |
75 | default: |
76 | break; |
77 | } |
78 | } |
79 | |
80 | final private Log _logger; |
81 | final private LoggingLevel _level; |
82 | } |