View Javadoc

1   /*
2    * $Id: Logger.java 269 2005-08-10 17:49:22Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.talika.tarsis.log;
24  
25  /**
26   * Interface that defines logger component in Tarsis MVC Framework.<br>
27   * <br>
28   * Logger interface defines methods to log messages, error messages and exceptions.<br>
29   * There are defined five log level messages: DEBUG, INFO, WARNING, ERROR and PANIC.<br>
30   *
31   * @author  Jose M. Palomar
32   * @version $Revision: 269 $
33   *
34   * @todo Revise interface to adopt log4j instead.
35   */
36  public interface Logger {
37  
38      // Constants
39      /**
40       * Debug level.
41       */
42      int DEBUG = 0;
43  
44      /**
45       * Information level.
46       */
47      int INFO = 1;
48  
49      /**
50       * Warning level.
51       */
52      int WARNING = 2;
53  
54      /**
55       * Error level.
56       */
57      int ERROR = 3;
58  
59      /**
60       * Panic level.
61       */
62      int PANIC = 4;
63  
64      // Methods
65      /**
66       * Returns log level.
67       *
68       * @return int log level.
69       */
70      int getLogLevel();
71  
72      /**
73       * Log a message using given level.
74       *
75       * @param level int log level.
76       * @param msg String message.
77       */
78      void log(int level, String msg);
79  
80      /**
81       * Log an error message using given level.
82       *
83       * @param level int log level.
84       * @param msg String message.
85       * @param t Throwable a <code>Throwable</code> object.
86       */
87      void log(int level, String msg, Throwable t);
88  
89      /**
90       * Log a message using debug level.
91       *
92       * @param msg String message.
93       */
94      void logDebug(String msg);
95  
96      /**
97       * Log a message using information level.
98       *
99       * @param msg String message.
100      */
101     void logInfo(String msg);
102 
103     /**
104      * Log a message using warning level.
105      *
106      * @param msg String message.
107      */
108     void logWarning(String msg);
109 
110     /**
111      * Log an error message using error level.
112      *
113      * @param msg String message.
114      * @param t Throwable a <code>Throwable</code> object.
115      */
116     void logError(String msg, Throwable t);
117 
118     /**
119      * Log a message using panic level.
120      *
121      * @param msg String message.
122      */
123     void logPanic(String msg);
124 
125     /**
126      * Log an error message using panic level.
127      *
128      * @param msg String message.
129      * @param t Throwable a <code>Throwable</code> object.
130      */
131     void logPanic(String msg, Throwable t);
132 
133     /**
134      * Returns <code>true</code> if log level is debug or higher.
135      *
136      * @return boolean <code>true</code> if log level is debug or higher.
137      */
138     boolean isDebugEnabled();
139 
140     /**
141      * Returns <code>true</code> if log level is info or higher.
142      *
143      * @return boolean <code>true</code> if log level is info or higher.
144      */
145     boolean isInfoEnabled();
146 
147     /**
148      * Returns <code>true</code> if log level is warning or higher.
149      *
150      * @return boolean <code>true</code> if log level is warning or higher.
151      */
152     boolean isWarningEnabled();
153 
154     /**
155      * Returns <code>true</code> if log level is error or higher.
156      *
157      * @return boolean <code>true</code> if log level is error or higher.
158      */
159     boolean isErrorEnabled();
160 
161     /**
162      * Returns <code>true</code> if log level is panic or higher.
163      *
164      * @return boolean <code>true</code> if log level is panic or higher.
165      */
166     boolean isPanicEnabled();
167 
168 }