01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 under
14: * the License.
15: */
16: package com.google.gwt.dev.shell.tomcat;
17:
18: import com.google.gwt.core.ext.TreeLogger;
19:
20: import org.apache.catalina.logger.LoggerBase;
21:
22: class CatalinaLoggerAdapter extends LoggerBase {
23:
24: private final TreeLogger logger;
25:
26: public CatalinaLoggerAdapter(TreeLogger logger) {
27: this .logger = logger;
28: }
29:
30: public void log(Exception exception, String msg) {
31: logger.log(TreeLogger.WARN, msg, exception);
32: }
33:
34: public void log(String msg) {
35: logger.log(TreeLogger.INFO, msg, null);
36: }
37:
38: public void log(String message, int verbosity) {
39: TreeLogger.Type type = mapVerbosityToLogType(verbosity);
40: logger.log(type, message, null);
41: }
42:
43: public void log(String msg, Throwable throwable) {
44: logger.log(TreeLogger.WARN, msg, throwable);
45: }
46:
47: public void log(String message, Throwable throwable, int verbosity) {
48: TreeLogger.Type type = mapVerbosityToLogType(verbosity);
49: logger.log(type, message, throwable);
50: }
51:
52: private TreeLogger.Type mapVerbosityToLogType(int verbosity) {
53: switch (verbosity) {
54: case LoggerBase.FATAL:
55: case LoggerBase.ERROR:
56: case LoggerBase.WARNING:
57: return TreeLogger.WARN;
58:
59: case LoggerBase.INFORMATION:
60: return TreeLogger.DEBUG;
61: case LoggerBase.DEBUG:
62: return TreeLogger.SPAM;
63:
64: default:
65: // really, this was an unexpected type
66: return TreeLogger.WARN;
67: }
68: }
69:
70: }
|