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 685685 2008-08-13 21:43:27Z nbubna $
37   * @deprecated This will be removed along with the RuntimeLogger interface.
38   * @since 1.5
39   */
40  public class RuntimeLoggerLog extends Log
41  {
42  
43      private RuntimeLogger rlog;
44  
45      /**
46       * Creates a new Log that wraps a PrimordialLogChute.
47       * @param rlog
48       */
49      public RuntimeLoggerLog(RuntimeLogger rlog)
50      {
51          if (rlog == null)
52          {
53              throw new NullPointerException("RuntimeLogger cannot be null!");
54          }
55          this.rlog = rlog;
56      }
57  
58      /**
59       * @see org.apache.velocity.runtime.log.Log#setLogChute(org.apache.velocity.runtime.log.LogChute)
60       */
61      protected void setLogChute(LogChute newLogChute)
62      {
63          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
64      }
65  
66      /**
67       * @see org.apache.velocity.runtime.log.Log#getLogChute()
68       */
69      protected LogChute getLogChute()
70      {
71          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
72      }
73  
74      /**
75       * @param showStacks
76       */
77      protected void setShowStackTraces(boolean showStacks)
78      {
79          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
80      }
81  
82      /**
83       * @return True if Stack traces should be shown.
84       */
85      public boolean getShowStackTraces()
86      {
87          throw new UnsupportedOperationException("RuntimeLoggerLog does not support this method.");
88      }
89  
90      /**
91       * @see org.apache.velocity.runtime.log.Log#isTraceEnabled()
92       */
93      public boolean isTraceEnabled()
94      {
95          return true;
96      }
97  
98      /**
99       * @see org.apache.velocity.runtime.log.Log#trace(java.lang.Object)
100      */
101     public void trace(Object message)
102     {
103         debug(message);
104     }
105 
106     /**
107      * @see org.apache.velocity.runtime.log.Log#trace(java.lang.Object, java.lang.Throwable)
108      */
109     public void trace(Object message, Throwable t)
110     {
111         debug(message, t);
112     }
113 
114     /**
115      * @see org.apache.velocity.runtime.log.Log#isDebugEnabled()
116      */
117     public boolean isDebugEnabled()
118     {
119         return true;
120     }
121 
122     /**
123      * @see org.apache.velocity.runtime.log.Log#debug(java.lang.Object)
124      */
125     public void debug(Object message)
126     {
127         rlog.debug(message);
128     }
129 
130     /**
131      * @see org.apache.velocity.runtime.log.Log#debug(java.lang.Object, java.lang.Throwable)
132      */
133     public void debug(Object message, Throwable t)
134     {
135         rlog.debug(message);
136         rlog.debug(t);
137     }
138 
139     /**
140      * @see org.apache.velocity.runtime.log.Log#isInfoEnabled()
141      */
142     public boolean isInfoEnabled()
143     {
144         return true;
145     }
146 
147     /**
148      * @see org.apache.velocity.runtime.log.Log#info(java.lang.Object)
149      */
150     public void info(Object message)
151     {
152         rlog.info(message);
153     }
154 
155     /**
156      * @see org.apache.velocity.runtime.log.Log#info(java.lang.Object, java.lang.Throwable)
157      */
158     public void info(Object message, Throwable t)
159     {
160         rlog.info(message);
161         rlog.info(t);
162     }
163 
164     /**
165      * @see org.apache.velocity.runtime.log.Log#isWarnEnabled()
166      */
167     public boolean isWarnEnabled()
168     {
169         return true;
170     }
171 
172     /**
173      * @see org.apache.velocity.runtime.log.Log#warn(java.lang.Object)
174      */
175     public void warn(Object message)
176     {
177         rlog.warn(message);
178     }
179 
180     /**
181      * @see org.apache.velocity.runtime.log.Log#warn(java.lang.Object, java.lang.Throwable)
182      */
183     public void warn(Object message, Throwable t)
184     {
185         rlog.warn(message);
186         rlog.warn(t);
187     }
188 
189     /**
190      * @see org.apache.velocity.runtime.log.Log#isErrorEnabled()
191      */
192     public boolean isErrorEnabled()
193     {
194         return true;
195     }
196 
197     /**
198      * @see org.apache.velocity.runtime.log.Log#error(java.lang.Object)
199      */
200     public void error(Object message)
201     {
202         rlog.error(message);
203     }
204 
205     /**
206      * @see org.apache.velocity.runtime.log.Log#error(java.lang.Object, java.lang.Throwable)
207      */
208     public void error(Object message, Throwable t)
209     {
210         rlog.error(message);
211         rlog.error(t);
212     }
213 
214 }