1 /*
2 * Copyright 2009 Red Hat, Inc.
3 *
4 * Red Hat licenses this file to you under the Apache License, version 2.0
5 * (the "License"); you may not use this file except in compliance with the
6 * License. You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16 package org.jboss.netty.logging;
17
18 /**
19 * A skeletal implementation of {@link InternalLogger}. This class implements
20 * all methods that have a {@link InternalLogLevel} parameter by default to call
21 * specific logger methods such as {@link #info(String)} or {@link #isInfoEnabled()}.
22 *
23 * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
24 * @author <a href="http://gleamynode.net/">Trustin Lee</a>
25 * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
26 */
27 public abstract class AbstractInternalLogger implements InternalLogger {
28
29 /**
30 * Creates a new instance.
31 */
32 protected AbstractInternalLogger() {
33 super();
34 }
35
36 public boolean isEnabled(InternalLogLevel level) {
37 switch (level) {
38 case DEBUG:
39 return isDebugEnabled();
40 case INFO:
41 return isInfoEnabled();
42 case WARN:
43 return isWarnEnabled();
44 case ERROR:
45 return isErrorEnabled();
46 default:
47 throw new Error();
48 }
49 }
50
51 public void log(InternalLogLevel level, String msg, Throwable cause) {
52 switch (level) {
53 case DEBUG:
54 debug(msg, cause);
55 break;
56 case INFO:
57 info(msg, cause);
58 break;
59 case WARN:
60 warn(msg, cause);
61 break;
62 case ERROR:
63 error(msg, cause);
64 break;
65 default:
66 throw new Error();
67 }
68 }
69
70 public void log(InternalLogLevel level, String msg) {
71 switch (level) {
72 case DEBUG:
73 debug(msg);
74 break;
75 case INFO:
76 info(msg);
77 break;
78 case WARN:
79 warn(msg);
80 break;
81 case ERROR:
82 error(msg);
83 break;
84 default:
85 throw new Error();
86 }
87 }
88 }