001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.kernel.log; 019 020 import org.apache.commons.logging.Log; 021 022 /** 023 * This log wrapper caches the trace, debug and info enabled flags. The flags are updated 024 * by a single timer task for all logs. 025 * 026 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ 027 */ 028 public final class GeronimoLog implements Log { 029 private final String name; 030 private Log log; 031 032 public GeronimoLog(String name, Log log) { 033 this.name = name; 034 this.log = log; 035 } 036 037 public String getName() { 038 return name; 039 } 040 041 public Log getLog() { 042 return log; 043 } 044 045 public void setLog(Log log) { 046 this.log = log; 047 } 048 049 public boolean isTraceEnabled() { 050 return log.isTraceEnabled(); 051 } 052 053 public void trace(Object message) { 054 log.trace(message); 055 } 056 057 public void trace(Object message, Throwable throwable) { 058 log.trace(message, throwable); 059 } 060 061 public boolean isDebugEnabled() { 062 return log.isDebugEnabled(); 063 } 064 065 public void debug(Object message) { 066 log.debug(message); 067 } 068 069 public void debug(Object message, Throwable throwable) { 070 log.debug(message, throwable); 071 } 072 073 public boolean isInfoEnabled() { 074 return log.isInfoEnabled(); 075 } 076 077 public void info(Object message) { 078 if(!name.startsWith("/")) { //todo: temporary fix to work around Jetty logging issue 079 log.info(message); 080 } 081 } 082 083 public void info(Object message, Throwable throwable) { 084 log.info(message, throwable); 085 } 086 087 public boolean isWarnEnabled() { 088 return log.isWarnEnabled(); 089 } 090 091 public void warn(Object message) { 092 log.warn(message); 093 } 094 095 public void warn(Object message, Throwable throwable) { 096 log.warn(message, throwable); 097 } 098 099 public boolean isErrorEnabled() { 100 return log.isErrorEnabled(); 101 } 102 103 public void error(Object message) { 104 log.error(message); 105 } 106 107 public void error(Object message, Throwable throwable) { 108 log.error(message, throwable); 109 } 110 111 public boolean isFatalEnabled() { 112 return log.isFatalEnabled(); 113 } 114 115 public void fatal(Object message) { 116 log.fatal(message); 117 } 118 119 public void fatal(Object message, Throwable throwable) { 120 log.fatal(message, throwable); 121 } 122 }