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 685685 2008-08-13 21:43:27Z nbubna $
32   * @since 1.5
33   */
34  public interface LogChute
35  {
36      /** Prefix string for trace messages. */
37      String TRACE_PREFIX = " [trace] ";
38  
39      /** Prefix string for debug messages. */
40      String DEBUG_PREFIX = " [debug] ";
41  
42      /** Prefix string for info messages. */
43      String INFO_PREFIX  = "  [info] ";
44  
45      /** Prefix string for warn messages. */
46      String WARN_PREFIX  = "  [warn] ";
47  
48      /** Prefix string for error messages. */
49      String ERROR_PREFIX = " [error] ";
50  
51      /** ID for trace messages. */
52      int TRACE_ID = -1;
53  
54      /** ID for debug messages. */
55      int DEBUG_ID = 0;
56  
57      /** ID for info messages. */
58      int INFO_ID = 1;
59  
60      /** ID for warning messages. */
61      int WARN_ID = 2;
62  
63      /** ID for error messages. */
64      int ERROR_ID = 3;
65  
66      /**
67       * Initializes this LogChute.
68       * @param rs
69       * @throws Exception
70       */
71      void init(RuntimeServices rs) throws Exception;
72  
73      /**
74       * Send a log message from Velocity.
75       * @param level
76       * @param message
77       */
78      void log(int level, String message);
79  
80      /**
81       * Send a log message from Velocity along with an exception or error
82       * @param level
83       * @param message
84       * @param t
85       */
86      void log(int level, String message, Throwable t);
87  
88      /**
89       * Tell whether or not a log level is enabled.
90       * @param level
91       * @return True if a level is enabled.
92       */
93      boolean isLevelEnabled(int level);
94  
95  }