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.RuntimeServices;
23  
24  /**
25   * Base interface that logging systems need to implement. This
26   * is the blessed descendant of the old LogSystem interface.
27   *
28   * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
29   * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
30   * @author <a href="mailto:nbubna@apache.org">Nathan Bubna</a>
31   * @version $Id: LogChute.java 494611 2007-01-09 21:57:20Z henning $
32   */
33  public interface LogChute
34  {
35      /** Prefix string for trace messages. */
36      String TRACE_PREFIX = " [trace] ";
37  
38      /** Prefix string for debug messages. */
39      String DEBUG_PREFIX = " [debug] ";
40  
41      /** Prefix string for info messages. */
42      String INFO_PREFIX  = "  [info] ";
43  
44      /** Prefix string for warn messages. */
45      String WARN_PREFIX  = "  [warn] ";
46  
47      /** Prefix string for error messages. */
48      String ERROR_PREFIX = " [error] ";
49  
50      /** ID for trace messages. */
51      int TRACE_ID = -1;
52  
53      /** ID for debug messages. */
54      int DEBUG_ID = 0;
55  
56      /** ID for info messages. */
57      int INFO_ID = 1;
58  
59      /** ID for warning messages. */
60      int WARN_ID = 2;
61  
62      /** ID for error messages. */
63      int ERROR_ID = 3;
64  
65      /**
66       * Initializes this LogChute.
67       * @param rs
68       * @throws Exception
69       */
70      void init(RuntimeServices rs) throws Exception;
71  
72      /**
73       * Send a log message from Velocity.
74       * @param level
75       * @param message
76       */
77      void log(int level, String message);
78  
79      /**
80       * Send a log message from Velocity along with an exception or error
81       * @param level
82       * @param message
83       * @param t
84       */
85      void log(int level, String message, Throwable t);
86  
87      /**
88       * Tell whether or not a log level is enabled.
89       * @param level
90       * @return True if a level is enabled.
91       */
92      boolean isLevelEnabled(int level);
93  
94  }