KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > utility > logging > Logger


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
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 Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.jdo.spi.persistence.utility.logging;
26
27 import java.util.ResourceBundle JavaDoc;
28 import java.security.SecurityPermission JavaDoc;
29
30 /** This interface provides an isolation layer between the JDO components
31  * that need logging services and the implementation of those services.
32  * <P>
33  * The JDO Logger interface contains a small number of convenience methods
34  * in addition to a subset of the
35  * methods in the java.util.logging.Logger class, and can therefore
36  * be implemented in a very straightforward way by a subclass of the
37  * java.util.logging.Logger class.
38  * There is one instance of the implementing class for each subsystem
39  * in JDO.
40  * <P>
41  * This interface has no JDK 1.4 dependencies.
42  */

43
44 public interface Logger {
45     
46     /** Levels are defined as ints to avoid including the java.util.logging.Level
47      * class in this package.
48      */

49     
50     /**
51      * OFF is a special level that can be used to turn off logging.
52      */

53     public static final int OFF = Integer.MAX_VALUE;
54
55     /**
56      * SEVERE is a message level indicating a serious failure.
57      * <p>
58      * In general SEVERE messages should describe events that are
59      * of considerable importance and which will prevent normal
60      * program execution. They should be reasonably intelligible
61      * to end users and to system administrators.
62      */

63     public static final int SEVERE = 1000;
64
65     /**
66      * WARNING is a message level indicating a potential problem.
67      * <p>
68      * In general WARNING messages should describe events that will
69      * be of interest to end users or system managers, or which
70      * indicate potential problems.
71      */

72     public static final int WARNING = 900;
73
74     /**
75      * INFO is a message level for informational messages.
76      * <p>
77      * Typically INFO messages will be written to the console
78      * or its equivalent. So the INFO level should only be
79      * used for reasonably significant messages that will
80      * make sense to end users and system admins.
81      */

82     public static final int INFO = 800;
83
84     /**
85      * CONFIG is a message level for static configuration messages.
86      * <p>
87      * CONFIG messages are intended to provide a variety of static
88      * configuration information, to assist in debugging problems
89      * that may be associated with particular configurations.
90      * For example, CONFIG message might include the CPU type,
91      * the graphics depth, the GUI look-and-feel, etc.
92      */

93     public static final int CONFIG = 700;
94
95     /**
96      * FINE is a message level providing tracing information.
97      * <p>
98      * All of FINE, FINER, and FINEST are intended for relatively
99      * detailed tracing. The exact meaning of the three levels will
100      * vary between subsystems, but in general, FINEST should be used
101      * for the most voluminous detailed output, FINER for somewhat
102      * less detailed output, and FINE for the lowest volume (and
103      * most important) messages.
104      * <p>
105      * In general the FINE level should be used for information
106      * that will be broadly interesting to developers who do not have
107      * a specialized interest in the specific subsystem.
108      * <p>
109      * FINE messages might include things like minor (recoverable)
110      * failures. Issues indicating potential performance problems
111      * are also worth logging as FINE.
112      */

113     public static final int FINE = 500;
114
115     /**
116      * FINER indicates a fairly detailed tracing message.
117      * By default logging calls for entering, returning, or throwing
118      * an exception are traced at this level.
119      */

120     public static final int FINER = 400;
121
122     /**
123      * FINEST indicates a highly detailed tracing message
124      */

125     public static final int FINEST = 300;
126
127     /**
128      * ALL indicates that all messages should be logged.
129      */

130     public static final int ALL = Integer.MIN_VALUE;
131     
132     /** Test if this logger is logging messages. This is a test for
133      * log level FINE, FINER, or FINEST. If the log message is expensive to construct,
134      * this method should be used to determine whether it is a waste of time.
135      * We don't expose isLoggable(Level) because Level is not available in
136      * JDK 1.3. Once this is not an issue, we can add isLoggable(Level).
137      * @return if FINE, FINER, or FINEST is currently being logged
138      */

139     public boolean isLoggable();
140     
141     /** Test if this logger is logging messages at the specific level.
142      * If the log message is expensive to construct,
143      * this method should be used to determine whether it is a waste of time.
144      * We don't expose isLoggable(Level) because Level is not available in
145      * JDK 1.3. Once this is not an issue, we can add isLoggable(Level).
146      * @return if this level is currently being logged
147      * @param level The level to be tested */

148     public boolean isLoggable(int level);
149     
150
151     //======================================================================
152
// Start of convenience methods for logging.
153
//======================================================================
154

155     /**
156      * Log a method entry.
157      * <p>
158      * This is a convenience method that can be used to log entry
159      * to a method. A LogRecord with message "ENTRY", log level
160      * FINER, and the given sourceMethod and sourceClass is logged.
161      * <p>
162      * @param sourceClass name of class that issued the logging request
163      * @param sourceMethod name of method that is being entered
164      */

165     public void entering(String JavaDoc sourceClass, String JavaDoc sourceMethod);
166
167     /**
168      * Log a method entry, with one parameter.
169      * <p>
170      * This is a convenience method that can be used to log entry
171      * to a method. A LogRecord with message "ENTRY {0}", log level
172      * FINER, and the given sourceMethod, sourceClass, and parameter
173      * is logged.
174      * <p>
175      * @param sourceClass name of class that issued the logging request
176      * @param sourceMethod name of method that is being entered
177      * @param param1 parameter to the method being entered
178      */

179     public void entering(String JavaDoc sourceClass, String JavaDoc sourceMethod, Object JavaDoc param1);
180
181     /**
182      * Log a method entry, with an array of parameters.
183      * <p>
184      * This is a convenience method that can be used to log entry
185      * to a method. A LogRecord with message "ENTRY" (followed by a
186      * format {N} indicator for each entry in the parameter array),
187      * log level FINER, and the given sourceMethod, sourceClass, and
188      * parameters is logged.
189      * <p>
190      * @param sourceClass name of class that issued the logging request
191      * @param sourceMethod name of method that is being entered
192      * @param params array of parameters to the method being entered
193      */

194     public void entering(String JavaDoc sourceClass, String JavaDoc sourceMethod, Object JavaDoc params[]);
195
196     /**
197      * Log a method return.
198      * <p>
199      * This is a convenience method that can be used to log returning
200      * from a method. A LogRecord with message "RETURN", log level
201      * FINER, and the given sourceMethod and sourceClass is logged.
202      * <p>
203      * @param sourceClass name of class that issued the logging request
204      * @param sourceMethod name of the method
205      */

206     public void exiting(String JavaDoc sourceClass, String JavaDoc sourceMethod);
207
208
209     /**
210      * Log a method return, with result object.
211      * <p>
212      * This is a convenience method that can be used to log returning
213      * from a method. A LogRecord with message "RETURN {0}", log level
214      * FINER, and the gives sourceMethod, sourceClass, and result
215      * object is logged.
216      * <p>
217      * @param sourceClass name of class that issued the logging request
218      * @param sourceMethod name of the method
219      * @param result Object that is being returned
220      */

221     public void exiting(String JavaDoc sourceClass, String JavaDoc sourceMethod, Object JavaDoc result);
222
223     /**
224      * Log throwing an exception.
225      * <p>
226      * This is a convenience method to log that a method is
227      * terminating by throwing an exception. The logging is done
228      * using the FINER level.
229      * <p>
230      * If the logger is currently enabled for the given message
231      * level then the given arguments are stored in a LogRecord
232      * which is forwarded to all registered output handlers. The
233      * LogRecord's message is set to "THROW".
234      * <p>
235      * Note that the thrown argument is stored in the LogRecord thrown
236      * property, rather than the LogRecord parameters property. Thus is it
237      * processed specially by output Formatters and is not treated
238      * as a formatting parameter to the LogRecord message property.
239      * <p>
240      * @param sourceClass name of class that issued the logging request
241      * @param sourceMethod name of the method.
242      * @param thrown The Throwable that is being thrown.
243      */

244     public void throwing(String JavaDoc sourceClass, String JavaDoc sourceMethod, Throwable JavaDoc thrown);
245
246     /**
247      * Log a SEVERE message.
248      * <p>
249      * If the logger is currently enabled for the SEVERE message
250      * level then the given message is forwarded to all the
251      * registered output Handler objects.
252      * <p>
253      * @param msg The string message (or a key in the message catalog)
254      */

255     public void severe(String JavaDoc msg);
256
257     /**
258      * Log a WARNING message.
259      * <p>
260      * If the logger is currently enabled for the WARNING message
261      * level then the given message is forwarded to all the
262      * registered output Handler objects.
263      * <p>
264      * @param msg The string message (or a key in the message catalog)
265      */

266     public void warning(String JavaDoc msg);
267
268     /**
269      * Log an INFO message.
270      * <p>
271      * If the logger is currently enabled for the INFO message
272      * level then the given message is forwarded to all the
273      * registered output Handler objects.
274      * <p>
275      * @param msg The string message (or a key in the message catalog)
276      */

277     public void info(String JavaDoc msg);
278
279     /**
280      * Log a CONFIG message.
281      * <p>
282      * If the logger is currently enabled for the CONFIG message
283      * level then the given message is forwarded to all the
284      * registered output Handler objects.
285      * <p>
286      * @param msg The string message (or a key in the message catalog)
287      */

288     public void config(String JavaDoc msg);
289
290     /**
291      * Log a message.
292      * <p>
293      * If the logger is currently enabled for the message
294      * level then the given message is forwarded to all the
295      * registered output Handler objects.
296      * <p>
297      * @param level The level for this message
298      * @param msg The string message (or a key in the message catalog)
299      */

300     public void log(int level, String JavaDoc msg);
301
302     /**
303      * Log a message.
304      * <p>
305      * If the logger is currently enabled for the message
306      * level then the given message is forwarded to all the
307      * registered output Handler objects.
308      * <p>
309      * @param level The level for this message
310      * @param msg The string message (or a key in the message catalog)
311      * @param o1 A parameter to be inserted into the message
312      */

313     public void log(int level, String JavaDoc msg, Object JavaDoc o1);
314
315     /**
316      * Log a message.
317      * <p>
318      * If the logger is currently enabled for the message
319      * level then the given message is forwarded to all the
320      * registered output Handler objects.
321      * <p>
322      * @param level The level for this message
323      * @param msg The string message (or a key in the message catalog)
324      * @param o Objects to be inserted into the message
325      */

326     public void log(int level, String JavaDoc msg, Object JavaDoc[] o);
327
328     /**
329      * Log a message.
330      * <p>
331      * If the logger is currently enabled for the message
332      * level then the given message is forwarded to all the
333      * registered output Handler objects.
334      * <p>
335      * @param level The level for this message
336      * @param msg The string message (or a key in the message catalog)
337      * @param o1 A parameter to be inserted into the message
338      * @param o2 A parameter to be inserted into the message
339      */

340     public void log(int level, String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2);
341
342     /**
343      * Log a message.
344      * <p>
345      * If the logger is currently enabled for the message
346      * level then the given message is forwarded to all the
347      * registered output Handler objects.
348      * <p>
349      * @param level The level for this message
350      * @param msg The string message (or a key in the message catalog)
351      * @param o1 A parameter to be inserted into the message
352      * @param o2 A parameter to be inserted into the message
353      * @param o3 A parameter to be inserted into the message
354      */

355     public void log(int level, String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2, Object JavaDoc o3);
356
357     /**
358      * Log a message.
359      * <p>
360      * If the logger is currently enabled for the message
361      * level then the given message, and the exception dump,
362      * is forwarded to all the
363      * registered output Handler objects.
364      * <p>
365      * @param level The level for this message
366      * @param msg The string message (or a key in the message catalog)
367      * @param thrown The exception to log
368      */

369     public void log(int level, String JavaDoc msg, Throwable JavaDoc thrown );
370
371     /**
372      * Log a message.
373      * <p>
374      * If the logger is currently enabled for the message
375      * level then the given message is forwarded to all the
376      * registered output Handler objects.
377      * <p>
378      * @param msg The string message (or a key in the message catalog)
379      */

380     public void fine(String JavaDoc msg);
381
382     /**
383      * Log a FINE message.
384      * <p>
385      * If the logger is currently enabled for the FINE message
386      * level then the given message is forwarded to all the
387      * registered output Handler objects.
388      * <p>
389      * @param msg The string message (or a key in the message catalog)
390      * @param o1 A parameter to be inserted into the message
391      */

392     public void fine(String JavaDoc msg, Object JavaDoc o1);
393
394     /**
395      * Log a FINE message.
396      * <p>
397      * If the logger is currently enabled for the FINE message
398      * level then the given message is forwarded to all the
399      * registered output Handler objects.
400      * <p>
401      * @param msg The string message (or a key in the message catalog)
402      * @param o Objects to be inserted into the message
403      */

404     public void fine(String JavaDoc msg, Object JavaDoc[] o);
405
406     /**
407      * Log a FINE message.
408      * <p>
409      * If the logger is currently enabled for the FINE message
410      * level then the given message is forwarded to all the
411      * registered output Handler objects.
412      * <p>
413      * @param msg The string message (or a key in the message catalog)
414      * @param o1 A parameter to be inserted into the message
415      * @param o2 A parameter to be inserted into the message
416      */

417     public void fine(String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2);
418
419     /**
420      * Log a FINE message.
421      * <p>
422      * If the logger is currently enabled for the FINE message
423      * level then the given message is forwarded to all the
424      * registered output Handler objects.
425      * <p>
426      * @param msg The string message (or a key in the message catalog)
427      * @param o1 A parameter to be inserted into the message
428      * @param o2 A parameter to be inserted into the message
429      * @param o3 A parameter to be inserted into the message
430      */

431     public void fine(String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2, Object JavaDoc o3);
432
433     /**
434      * Log a FINER message.
435      * <p>
436      * If the logger is currently enabled for the FINER message
437      * level then the given message is forwarded to all the
438      * registered output Handler objects.
439      * <p>
440      * @param msg The string message (or a key in the message catalog)
441      */

442     public void finer(String JavaDoc msg);
443
444     /**
445      * Log a FINER message.
446      * <p>
447      * If the logger is currently enabled for the FINER message
448      * level then the given message is forwarded to all the
449      * registered output Handler objects.
450      * <p>
451      * @param msg The string message (or a key in the message catalog)
452      * @param o Objects to be inserted into the message
453      */

454     public void finer(String JavaDoc msg, Object JavaDoc[] o);
455
456     /**
457      * Log a FINER message.
458      * <p>
459      * If the logger is currently enabled for the FINER message
460      * level then the given message is forwarded to all the
461      * registered output Handler objects.
462      * <p>
463      * @param msg The string message (or a key in the message catalog)
464      * @param o1 A parameter to be inserted into the message
465      */

466     public void finer(String JavaDoc msg, Object JavaDoc o1);
467
468     /**
469      * Log a FINER message.
470      * <p>
471      * If the logger is currently enabled for the FINER message
472      * level then the given message is forwarded to all the
473      * registered output Handler objects.
474      * <p>
475      * @param msg The string message (or a key in the message catalog)
476      * @param o1 A parameter to be inserted into the message
477      * @param o2 A parameter to be inserted into the message
478      */

479     public void finer(String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2);
480
481     /**
482      * Log a FINER message.
483      * <p>
484      * If the logger is currently enabled for the FINER message
485      * level then the given message is forwarded to all the
486      * registered output Handler objects.
487      * <p>
488      * @param msg The string message (or a key in the message catalog)
489      * @param o1 A parameter to be inserted into the message
490      * @param o2 A parameter to be inserted into the message
491      * @param o3 A parameter to be inserted into the message
492      */

493     public void finer(String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2, Object JavaDoc o3);
494
495     /**
496      * Log a FINEST message.
497      * <p>
498      * If the logger is currently enabled for the FINEST message
499      * level then the given message is forwarded to all the
500      * registered output Handler objects.
501      * <p>
502      * @param msg The string message (or a key in the message catalog)
503      */

504     public void finest(String JavaDoc msg);
505
506     /**
507      * Log a FINEST message.
508      * <p>
509      * If the logger is currently enabled for the FINEST message
510      * level then the given message is forwarded to all the
511      * registered output Handler objects.
512      * <p>
513      * @param msg The string message (or a key in the message catalog)
514      * @param o Objects to be inserted into the message
515      */

516     public void finest(String JavaDoc msg, Object JavaDoc[] o);
517
518     /**
519      * Log a FINEST message.
520      * <p>
521      * If the logger is currently enabled for the FINEST message
522      * level then the given message is forwarded to all the
523      * registered output Handler objects.
524      * <p>
525      * @param msg The string message (or a key in the message catalog)
526      * @param o1 A parameter to be inserted into the message
527      */

528     public void finest(String JavaDoc msg, Object JavaDoc o1);
529
530     /**
531      * Log a FINEST message.
532      * <p>
533      * If the logger is currently enabled for the FINEST message
534      * level then the given message is forwarded to all the
535      * registered output Handler objects.
536      * <p>
537      * @param msg The string message (or a key in the message catalog)
538      * @param o1 A parameter to be inserted into the message
539      * @param o2 A parameter to be inserted into the message
540      */

541     public void finest(String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2);
542
543     /**
544      * Log a FINEST message.
545      * <p>
546      * If the logger is currently enabled for the FINEST message
547      * level then the given message is forwarded to all the
548      * registered output Handler objects.
549      * <p>
550      * @param msg The string message (or a key in the message catalog)
551      * @param o1 A parameter to be inserted into the message
552      * @param o2 A parameter to be inserted into the message
553      * @param o3 A parameter to be inserted into the message
554      */

555     public void finest(String JavaDoc msg, Object JavaDoc o1, Object JavaDoc o2, Object JavaDoc o3);
556
557     //================================================================
558
// End of convenience methods
559
//================================================================
560

561     /**
562      * Get the name for this logger.
563      * @return logger name. Will be null for anonymous Loggers.
564      */

565     public String JavaDoc getName();
566
567 }
568
Popular Tags