KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > logging > SessionLog


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.logging;
23
24 import java.io.Writer JavaDoc;
25 import oracle.toplink.essentials.sessions.Session;
26
27 /**
28  * SessionLog is the ever-so-simple interface used by
29  * TopLink to log generated messages and SQL. An implementor of
30  * this interface can be passed to the TopLink session
31  * (via the #setSessionLog(SessionLog) method); and
32  * all logging data will be passed through to the implementor
33  * via an instance of SessionLogEntry. This can be used
34  * to supplement debugging; or the entries could be stored
35  * in a database instead of logged to System.out; etc.
36  *
37  * @see AbstractSessionLog
38  * @see SessionLogEntry
39  *
40  * @since TOPLink/Java 3.0
41  */

42 public interface SessionLog {
43     //TopLink log levels. They are mapped to java.util.logging.Level values
44
public static final int OFF = 8;
45
46     //TL is not in a state to continue
47
public static final int SEVERE = 7;
48
49     //Exceptions that don't force a stop
50
public static final int WARNING = 6;
51
52     //Login and logout per server session with name
53
public static final int INFO = 5;
54
55     //Configuration info
56
public static final int CONFIG = 4;
57
58     //SQL
59
public static final int FINE = 3;
60
61     //Previously logged under logMessage and stack trace of exceptions at WARNING level
62
public static final int FINER = 2;
63
64     //Previously logged under logDebug
65
public static final int FINEST = 1;
66     public static final int ALL = 0;
67
68     //TopLink categories used for logging name space.
69
//If you add a new category, please Please ensure to add it to
70
//loggerCatagories array below
71
public static final String JavaDoc SQL = "sql";
72     public static final String JavaDoc TRANSACTION = "transaction";
73     public static final String JavaDoc EVENT = "event";
74     public static final String JavaDoc CONNECTION = "connection";
75     public static final String JavaDoc QUERY = "query";
76     public static final String JavaDoc CACHE = "cache";
77     public static final String JavaDoc PROPAGATION = "propagation";
78     public static final String JavaDoc SEQUENCING = "sequencing";
79     public static final String JavaDoc EJB = "ejb";
80     public static final String JavaDoc DMS = "dms";
81     public static final String JavaDoc EJB_ANNOTATION = "ejb_annotation";
82     public static final String JavaDoc EJB_ORM = "ejb_orm";
83     public static final String JavaDoc WEAVER = "weaver";
84     public static final String JavaDoc PROPERTIES = "properties";
85     public final String JavaDoc[] loggerCatagories = new String JavaDoc[] { SQL ,TRANSACTION ,EVENT ,CONNECTION ,QUERY ,CACHE ,PROPAGATION ,SEQUENCING ,EJB ,DMS ,EJB_ANNOTATION ,EJB_ORM ,WEAVER ,PROPERTIES};
86
87     /**
88      * INTERNAL:
89      * TopLink will call this method whenever something
90      * needs to be logged (messages, SQL, etc.).
91      * All the pertinent information will be contained in
92      * the specified entry.
93      *
94      * @param entry oracle.toplink.essentials.sessions.LogEntry
95      */

96     void log(SessionLogEntry entry);
97
98     /**
99      * By default the stack trace is logged for SEVERE all the time and at FINER level for WARNING or less,
100      * this can be turned off.
101      */

102     boolean shouldLogExceptionStackTrace();
103
104     /**
105      * By default the date is always printed, this can be turned off.
106      */

107     boolean shouldPrintDate();
108
109     /**
110      * By default the thread is logged at FINE or less level, this can be turned off.
111      */

112     boolean shouldPrintThread();
113
114     /**
115      * By default the connection is always printed whenever available, this can be turned off.
116      */

117     boolean shouldPrintConnection();
118
119     /**
120      * By default the Session is always printed whenever available, this can be turned off.
121      */

122     boolean shouldPrintSession();
123
124     /**
125      * By default stack trace is logged for SEVERE all the time and at FINER level for WARNING or less.
126      * This can be turned off.
127      */

128     void setShouldLogExceptionStackTrace(boolean flag);
129
130     /**
131      * By default date is printed, this can be turned off.
132      */

133     void setShouldPrintDate(boolean flag);
134
135     /**
136      * By default the thread is logged at FINE or less level, this can be turned off.
137      */

138     void setShouldPrintThread(boolean flag);
139
140     /**
141      * By default the connection is always printed whenever available, this can be turned off.
142      */

143     void setShouldPrintConnection(boolean flag);
144
145     /**
146      * By default the Session is always printed whenever available, this can be turned off.
147      */

148     void setShouldPrintSession(boolean flag);
149
150     /**
151      * PUBLIC:
152      * Return the writer to which an accessor writes logged messages and SQL.
153      * If not set, this reference usually defaults to a writer on System.out.
154      * To enable logging, logMessages must be turned on in the session.
155      */

156     Writer JavaDoc getWriter();
157
158     /**
159      * PUBLIC:
160      * Set the writer to which an accessor writes logged messages and SQL.
161      * If not set, this reference usually defaults to a writer on System.out.
162      * To enable logging, logMessages() is used on the session.
163      */

164     void setWriter(Writer JavaDoc log);
165
166     /**
167      * PUBLIC:
168      * Return the log level. Used when session is not available.
169      */

170     int getLevel();
171
172     /**
173      * PUBLIC:
174      * Return the log level. category is only needed where name space
175      * is available.
176      */

177     int getLevel(String JavaDoc category);
178
179     /**
180      * PUBLIC:
181      * Set the log level. Used when session is not available.
182      */

183     void setLevel(int level);
184
185     /**
186      * PUBLIC:
187      * Set the log level. Category is only needed where name space
188      * is available.
189      */

190     void setLevel(int level, String JavaDoc category);
191
192     /**
193      * PUBLIC:
194      * Check if a message of the given level would actually be logged.
195      * Used when session is not available.
196      */

197     boolean shouldLog(int level);
198
199     /**
200      * PUBLIC:
201      * Check if a message of the given level would actually be logged.
202      * Category is only needed where name space is available.
203      */

204     boolean shouldLog(int level, String JavaDoc category);
205
206     /**
207      * PUBLIC:
208      * Log a message that does not need to be translated. This method is intended for
209      * external use when logging messages are wanted within the TopLink output.
210      */

211     void log(int level, String JavaDoc message);
212
213     /**
214      * INTERNAL:
215      * Log a message with one parameter that needs to be translated.
216      */

217     public void log(int level, String JavaDoc message, Object JavaDoc param);
218
219     /**
220      * INTERNAL:
221      * Log a message with two parameters that needs to be translated.
222      */

223     void log(int level, String JavaDoc message, Object JavaDoc param1, Object JavaDoc param2);
224
225     /**
226      * INTERNAL:
227      * Log a message with three parameters that needs to be translated.
228      */

229     void log(int level, String JavaDoc message, Object JavaDoc param1, Object JavaDoc param2, Object JavaDoc param3);
230
231     /**
232      * INTERNAL:
233      * This method is called when the log request is from somewhere session is not available.
234      * The message needs to be translated.
235      */

236     void log(int level, String JavaDoc message, Object JavaDoc[] arguments);
237
238     /**
239      * INTERNAL:
240      * This method is called when the log request is from somewhere session is not available.
241      * shouldTranslate flag determines if the message needs to be translated.
242      */

243     void log(int level, String JavaDoc message, Object JavaDoc[] arguments, boolean shouldTranslate);
244
245     /**
246      * PUBLIC:
247      * This method is called when a throwable at finer level needs to be logged.
248      */

249     void throwing(Throwable JavaDoc throwable);
250
251     /**
252      * PUBLIC:
253      * This method is called when a severe level message needs to be logged.
254      * The message will be translated
255      */

256     void severe(String JavaDoc message);
257
258     /**
259      * PUBLIC:
260      * This method is called when a warning level message needs to be logged.
261      * The message will be translated
262      */

263     void warning(String JavaDoc message);
264
265     /**
266      * PUBLIC:
267      * This method is called when a info level message needs to be logged.
268      * The message will be translated
269      */

270     void info(String JavaDoc message);
271
272     /**
273      * PUBLIC:
274      * This method is called when a config level message needs to be logged.
275      * The message will be translated
276      */

277     void config(String JavaDoc message);
278
279     /**
280      * PUBLIC:
281      * This method is called when a fine level message needs to be logged.
282      * The message will be translated
283      */

284     void fine(String JavaDoc message);
285
286     /**
287      * PUBLIC:
288      * This method is called when a finer level message needs to be logged.
289      * The message will be translated
290      */

291     void finer(String JavaDoc message);
292
293     /**
294      * PUBLIC:
295      * This method is called when a finest level message needs to be logged.
296      * The message will be translated
297      */

298     void finest(String JavaDoc message);
299
300     /**
301      * PUBLIC:
302      * Log a throwable with level.
303      */

304     void logThrowable(int level, Throwable JavaDoc throwable);
305
306     /**
307      * PUBLIC:
308      * Get the session that owns this SessionLog.
309      */

310     Session getSession();
311
312     /**
313      * PUBLIC:
314      * Set the session that owns this SessionLog.
315      */

316     void setSession(Session session);
317 }
318
Popular Tags