KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > util > BasicLoggerImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library 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 GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.corba.util;
28
29 /**
30  * BasicLoggerImpl is a basic logger implementation.
31  *
32  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
33  *
34  * @version 0.1
35  *
36  * TODO: The implementation must use MonoLog!!!
37  */

38
39 public class BasicLoggerImpl
40   implements Logger
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      * This boolean indicates if trace logging is active or not.
50      */

51     public static final boolean isTraceLogged = false ;//true;
52

53     /**
54      * This boolean indicates if error logging is active or not.
55      */

56     public static final boolean isErrorLogged = false ;//true;
57

58     /**
59      * Output where trace and error messages are logged.
60      */

61     protected java.io.PrintStream JavaDoc output_ = System.err;
62
63     // ==================================================================
64
//
65
// Constructor.
66
//
67
// ==================================================================
68

69     /** The default constructor. */
70     public
71     BasicLoggerImpl()
72     {
73     }
74
75     // ==================================================================
76
//
77
// Internal methods.
78
//
79
// ==================================================================
80
// ==================================================================
81
//
82
// Public methods for Logger
83
//
84
// ==================================================================
85

86     /**
87      * Logs a trace message.
88      *
89      * @param caller The caller object.
90      * @param message The trace message to log.
91      *
92      * TODO: The implementation must use MonoLog!!!
93      */

94     public
95     void trace(Object JavaDoc caller,
96                String JavaDoc message)
97     {
98         if(isTraceLogged) {
99             output_.println(caller + ": " + message + '.');
100     }
101     }
102
103     /**
104      * Logs an error message.
105      *
106      * @param caller The caller object.
107      * @param message The error message to log.
108      *
109      * TODO: The implementation must use MonoLog!!!
110      */

111     public
112     void error(Object JavaDoc caller,
113                String JavaDoc message)
114     {
115         if(isErrorLogged) {
116             try {
117                 throw new Error JavaDoc(message);
118             } catch (Error JavaDoc exc) {
119                 output_.print(caller + ": " + message + "!!!");
120                 exc.printStackTrace();
121             }
122         }
123     }
124
125     // ==================================================================
126
//
127
// Public methods.
128
//
129
// ==================================================================
130
}
131
Popular Tags