View Javadoc

1   package org.apache.velocity.runtime.log;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.    
20   */
21  
22  import org.apache.velocity.runtime.RuntimeLogger;
23  
24  /**
25   * A temporary RuntimeLogger wrapper to make the deprecation
26   * of UberspectLoggable.setRuntimeLogger(RuntimeLogger) feasible.
27   * This overrides all Log methods, either throwing
28   * UnsupportedOperationExceptions or passing things off to the
29   * theoretical RuntimeLogger used to create it.  Oh, and all the
30   * is<Level>Enabled() methods return true.  Of course, ideally
31   * there is no one out there who actually created their own
32   * RuntimeLogger instance to use with UberspectLoggable.setRuntimeLogger()
33   * and this class will therefore never be used.  But it's here just in case.
34   *
35   * @author <a href="mailto:nbubna@apache.org">Nathan Bubna</a>
36   * @version $Id: RuntimeLoggerLog.java 463298 2006-10-12 16:10:32Z henning $
37   * @deprecated This will be removed along with the RuntimeLogger interface.
38   */
39  public class RuntimeLoggerLog extends Log
40  {
41  
42      private RuntimeLogger rlog;
43  
44      /**
45       * Creates a new Log that wraps a PrimordialLogChute.
46       * @param rlog
47       */
48      public RuntimeLoggerLog(RuntimeLogger rlog)
49      {
50          if (rlog == null)
51          {
52              throw new NullPointerException("RuntimeLogger cannot be null!");
53          }
54          this.rlog = rlog;
55      }
56  
57      /**
58       * @see org.apache.velocity.runtime.log.Log#setLogChute(org.apache.velocity.runtime.log.LogChute)
59       */
60      protected void setLogChute(LogChute newLogChute)
61      {
62          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
63      }
64  
65      /**
66       * @see org.apache.velocity.runtime.log.Log#getLogChute()
67       */
68      protected LogChute getLogChute()
69      {
70          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
71      }
72  
73      /**
74       * @param showStacks
75       */
76      protected void setShowStackTraces(boolean showStacks)
77      {
78          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
79      }
80  
81      /**
82       * @return True if Stack traces should be shown.
83       */
84      public boolean getShowStackTraces()
85      {
86          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
87      }
88  
89      /**
90       * @see org.apache.velocity.runtime.log.Log#isTraceEnabled()
91       */
92      public boolean isTraceEnabled()
93      {
94          return true;
95      }
96  
97      /**
98       * @see org.apache.velocity.runtime.log.Log#trace(java.lang.Object)
99       */
100     public void trace(Object message)
101     {
102         debug(message);
103     }
104 
105     /**
106      * @see org.apache.velocity.runtime.log.Log#trace(java.lang.Object, java.lang.Throwable)
107      */
108     public void trace(Object message, Throwable t)
109     {
110         debug(message, t);
111     }
112 
113     /**
114      * @see org.apache.velocity.runtime.log.Log#isDebugEnabled()
115      */
116     public boolean isDebugEnabled()
117     {
118         return true;
119     }
120 
121     /**
122      * @see org.apache.velocity.runtime.log.Log#debug(java.lang.Object)
123      */
124     public void debug(Object message)
125     {
126         rlog.debug(message);
127     }
128 
129     /**
130      * @see org.apache.velocity.runtime.log.Log#debug(java.lang.Object, java.lang.Throwable)
131      */
132     public void debug(Object message, Throwable t)
133     {
134         rlog.debug(message);
135         rlog.debug(t);
136     }
137 
138     /**
139      * @see org.apache.velocity.runtime.log.Log#isInfoEnabled()
140      */
141     public boolean isInfoEnabled()
142     {
143         return true;
144     }
145 
146     /**
147      * @see org.apache.velocity.runtime.log.Log#info(java.lang.Object)
148      */
149     public void info(Object message)
150     {
151         rlog.info(message);
152     }
153 
154     /**
155      * @see org.apache.velocity.runtime.log.Log#info(java.lang.Object, java.lang.Throwable)
156      */
157     public void info(Object message, Throwable t)
158     {
159         rlog.info(message);
160         rlog.info(t);
161     }
162 
163     /**
164      * @see org.apache.velocity.runtime.log.Log#isWarnEnabled()
165      */
166     public boolean isWarnEnabled()
167     {
168         return true;
169     }
170 
171     /**
172      * @see org.apache.velocity.runtime.log.Log#warn(java.lang.Object)
173      */
174     public void warn(Object message)
175     {
176         rlog.warn(message);
177     }
178 
179     /**
180      * @see org.apache.velocity.runtime.log.Log#warn(java.lang.Object, java.lang.Throwable)
181      */
182     public void warn(Object message, Throwable t)
183     {
184         rlog.warn(message);
185         rlog.warn(t);
186     }
187 
188     /**
189      * @see org.apache.velocity.runtime.log.Log#isErrorEnabled()
190      */
191     public boolean isErrorEnabled()
192     {
193         return true;
194     }
195 
196     /**
197      * @see org.apache.velocity.runtime.log.Log#error(java.lang.Object)
198      */
199     public void error(Object message)
200     {
201         rlog.error(message);
202     }
203 
204     /**
205      * @see org.apache.velocity.runtime.log.Log#error(java.lang.Object, java.lang.Throwable)
206      */
207     public void error(Object message, Throwable t)
208     {
209         rlog.error(message);
210         rlog.error(t);
211     }
212 
213 }