001: package org.apache.velocity.runtime.log;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.apache.velocity.runtime.RuntimeLogger;
023:
024: /**
025: * A temporary RuntimeLogger wrapper to make the deprecation
026: * of UberspectLoggable.setRuntimeLogger(RuntimeLogger) feasible.
027: * This overrides all Log methods, either throwing
028: * UnsupportedOperationExceptions or passing things off to the
029: * theoretical RuntimeLogger used to create it. Oh, and all the
030: * is<Level>Enabled() methods return true. Of course, ideally
031: * there is no one out there who actually created their own
032: * RuntimeLogger instance to use with UberspectLoggable.setRuntimeLogger()
033: * and this class will therefore never be used. But it's here just in case.
034: *
035: * @author <a href="mailto:nbubna@apache.org">Nathan Bubna</a>
036: * @version $Id: RuntimeLoggerLog.java 463298 2006-10-12 16:10:32Z henning $
037: * @deprecated This will be removed along with the RuntimeLogger interface.
038: */
039: public class RuntimeLoggerLog extends Log {
040:
041: private RuntimeLogger rlog;
042:
043: /**
044: * Creates a new Log that wraps a PrimordialLogChute.
045: * @param rlog
046: */
047: public RuntimeLoggerLog(RuntimeLogger rlog) {
048: if (rlog == null) {
049: throw new NullPointerException(
050: "RuntimeLogger cannot be null!");
051: }
052: this .rlog = rlog;
053: }
054:
055: /**
056: * @see org.apache.velocity.runtime.log.Log#setLogChute(org.apache.velocity.runtime.log.LogChute)
057: */
058: protected void setLogChute(LogChute newLogChute) {
059: throw new UnsupportedOperationException(
060: "RuntimeLoggerLog does not support this method.");
061: }
062:
063: /**
064: * @see org.apache.velocity.runtime.log.Log#getLogChute()
065: */
066: protected LogChute getLogChute() {
067: throw new UnsupportedOperationException(
068: "RuntimeLoggerLog does not support this method.");
069: }
070:
071: /**
072: * @param showStacks
073: */
074: protected void setShowStackTraces(boolean showStacks) {
075: throw new UnsupportedOperationException(
076: "RuntimeLoggerLog does not support this method.");
077: }
078:
079: /**
080: * @return True if Stack traces should be shown.
081: */
082: public boolean getShowStackTraces() {
083: throw new UnsupportedOperationException(
084: "RuntimeLoggerLog does not support this method.");
085: }
086:
087: /**
088: * @see org.apache.velocity.runtime.log.Log#isTraceEnabled()
089: */
090: public boolean isTraceEnabled() {
091: return true;
092: }
093:
094: /**
095: * @see org.apache.velocity.runtime.log.Log#trace(java.lang.Object)
096: */
097: public void trace(Object message) {
098: debug(message);
099: }
100:
101: /**
102: * @see org.apache.velocity.runtime.log.Log#trace(java.lang.Object, java.lang.Throwable)
103: */
104: public void trace(Object message, Throwable t) {
105: debug(message, t);
106: }
107:
108: /**
109: * @see org.apache.velocity.runtime.log.Log#isDebugEnabled()
110: */
111: public boolean isDebugEnabled() {
112: return true;
113: }
114:
115: /**
116: * @see org.apache.velocity.runtime.log.Log#debug(java.lang.Object)
117: */
118: public void debug(Object message) {
119: rlog.debug(message);
120: }
121:
122: /**
123: * @see org.apache.velocity.runtime.log.Log#debug(java.lang.Object, java.lang.Throwable)
124: */
125: public void debug(Object message, Throwable t) {
126: rlog.debug(message);
127: rlog.debug(t);
128: }
129:
130: /**
131: * @see org.apache.velocity.runtime.log.Log#isInfoEnabled()
132: */
133: public boolean isInfoEnabled() {
134: return true;
135: }
136:
137: /**
138: * @see org.apache.velocity.runtime.log.Log#info(java.lang.Object)
139: */
140: public void info(Object message) {
141: rlog.info(message);
142: }
143:
144: /**
145: * @see org.apache.velocity.runtime.log.Log#info(java.lang.Object, java.lang.Throwable)
146: */
147: public void info(Object message, Throwable t) {
148: rlog.info(message);
149: rlog.info(t);
150: }
151:
152: /**
153: * @see org.apache.velocity.runtime.log.Log#isWarnEnabled()
154: */
155: public boolean isWarnEnabled() {
156: return true;
157: }
158:
159: /**
160: * @see org.apache.velocity.runtime.log.Log#warn(java.lang.Object)
161: */
162: public void warn(Object message) {
163: rlog.warn(message);
164: }
165:
166: /**
167: * @see org.apache.velocity.runtime.log.Log#warn(java.lang.Object, java.lang.Throwable)
168: */
169: public void warn(Object message, Throwable t) {
170: rlog.warn(message);
171: rlog.warn(t);
172: }
173:
174: /**
175: * @see org.apache.velocity.runtime.log.Log#isErrorEnabled()
176: */
177: public boolean isErrorEnabled() {
178: return true;
179: }
180:
181: /**
182: * @see org.apache.velocity.runtime.log.Log#error(java.lang.Object)
183: */
184: public void error(Object message) {
185: rlog.error(message);
186: }
187:
188: /**
189: * @see org.apache.velocity.runtime.log.Log#error(java.lang.Object, java.lang.Throwable)
190: */
191: public void error(Object message, Throwable t) {
192: rlog.error(message);
193: rlog.error(t);
194: }
195:
196: }
|