KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > qfs > apps > qflog > logview > InternalLogLevelCallback


1 // {{{ copyright
2

3 /********************************************************************
4  *
5  * $Id: InternalLogLevelCallback.java,v 1.1 2000/07/04 13:47:31 gs Exp $
6  *
7  * The contents of this file are subject to the Mozilla Public
8  * License Version 1.1 (the "License"); you may not use this file
9  * except in compliance with the License. You may obtain a copy of
10  * the License at http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS
13  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14  * implied. See the License for the specific language governing
15  * rights and limitations under the License.
16  *
17  * The Original Code is qfs.de code.
18  *
19  * The Initial Developer of the Original Code is Gregor Schmid.
20  * Portions created by Gregor Schmid are
21  * Copyright (C) 2000 Quality First Software, Gregor Schmid.
22  * All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  *******************************************************************/

27
28 // }}}
29

30 package de.qfs.apps.qflog.logview;
31
32 // {{{ imports
33

34 import de.qfs.lib.log.Log;
35 import de.qfs.lib.log.Logger;
36 import de.qfs.lib.log.LogLevelCallback;
37 import de.qfs.lib.log.LogLevelListener;
38
39 // }}}
40

41 /**
42  * LogLevelCallback for a LogView that is integrated directly into an
43  * application.
44  *
45  * @author Gregor Schmid
46  * @version $Revision: 1.1 $
47  */

48 public class InternalLogLevelCallback
49     implements LogLevelCallback
50 {
51     // {{{ variables
52

53     /**
54      * The LogLevelListener to which the callback is connected.
55      */

56     private LogLevelListener listener;
57
58     // }}}
59

60     // {{{ constructor
61

62     /**
63      * Create a new InternalLogLevelCallback.
64      *
65      * @param listener The LogLevelListener to which the callback is
66      * connected.
67      */

68     public InternalLogLevelCallback (LogLevelListener listener)
69     {
70         this.listener = listener;
71     }
72
73     // }}}
74

75     //----------------------------------------------------------------------
76
// The LogLevelCallback interface
77
//----------------------------------------------------------------------
78
// {{{ getLogLevels
79

80     /**
81      * Get the current log levels from the callback. This method is needed to
82      * synchronize the LogLevelListener and the LogLevelCallback after the
83      * connection has been established.
84      *
85      * @return An object array that contains an alternating sequence of
86      * class/package names and log levels. The levels are Integers
87      * that may be null for classes for which a level has been
88      * requested but not explicitly set.
89      */

90     public Object JavaDoc[] getLogLevels()
91     {
92         return Logger.getLogLevels();
93     }
94
95     // }}}
96
// {{{ setLogLevel
97

98     /**
99      * Callback method for a LogLevelListener to change the log level for
100      * a class or package.
101      *
102      * @param source The listener that causes the change. It will not be
103      * notified to avoid recursion.
104      * @param name The name of the affected class or package.
105      * @param level The new log level.
106      */

107     public void setLogLevel(String JavaDoc name, int level)
108     {
109         Logger.setLogLevel(listener, name, level);
110     }
111
112     // }}}
113
// {{{ removeLogLevel
114

115     /**
116      * Callback method for a LogLevelListener to remove the log level for
117      * a class or package.
118      *
119      * @param source The listener that causes the change. It will not be
120      * notified to avoid recursion.
121      * @param name The name of the affected class or package.
122      */

123     public void removeLogLevel(String JavaDoc name)
124     {
125         Logger.removeLogLevel(listener, name);
126     }
127
128     // }}}
129
// {{{ getOutputLevel
130

131     /**
132      * Get the current output log level from the callback's application.
133      *
134      * @return The current output log level.
135      */

136     public int getOutputLevel()
137     {
138         return Log.getOutputLevel();
139     }
140
141     // }}}
142
// {{{ setOutputLevel
143

144     /**
145      * Set the output log level for the callback's application.
146      *
147      * @param level Output log level to set.
148      */

149     public void setOutputLevel(int level)
150     {
151         Log.setOutputLevel(level);
152     }
153
154     // }}}
155
// {{{ getPreQueueLevel
156

157     /**
158      * Return the current pre-queue level from the callback's application.
159      *
160      * @return The current pre-queue level.
161      */

162     public int getPreQueueLevel()
163     {
164         return Log.getPreQueueLevel();
165     }
166
167     // }}}
168
// {{{ setPreQueueLevel
169

170     /**
171      * Set the pre-queue level for the callback's application.
172      *
173      * @param level The pre-queue level to set.
174      */

175     public void setPreQueueLevel(int level)
176     {
177         Log.setPreQueueLevel(level);
178     }
179
180     // }}}
181
// {{{ isQueueing
182

183     /**
184      * Check whether the callback's application is using a log queue.
185      *
186      * @return Whether the callback's application is queueing log entries.
187      *
188      * @see Log#isQueueing
189      */

190     public boolean isQueueing()
191     {
192         return Log.isQueueing();
193     }
194
195     // }}}
196
// {{{ setQueueing
197

198     /**
199      * Set whether the callback's application should use a log queue.
200      *
201      * @param queue Whether to queue log entries.
202      *
203      * @see Log#setQueueing
204      */

205     public void setQueueing(boolean queue)
206     {
207         Log.setQueueing(queue);
208     }
209
210     // }}}
211
// {{{ getQueueSize
212

213     /**
214      * Get the size of log queue of the callback's application.
215      *
216      * @return The size of the log queue.
217      *
218      * @see Log#getQueueSize
219      */

220     public int getQueueSize()
221     {
222         return Log.getQueueSize();
223     }
224
225     // }}}
226
// {{{ setQueueSize
227

228     /**
229      * Set the size of log queue of the callback's application.
230      *
231      * @param size The size of the log queue.
232      *
233      * @see Log#setQueueSize
234      */

235     public void setQueueSize(int size)
236     {
237         Log.setQueueSize(size);
238     }
239
240     // }}}
241
// {{{ isDropOnOverflow
242

243     /**
244      * Check whether the callback's application is dropping entries when
245      * its log queue overflows.
246      *
247      * @return Whether entries are dropped on overflow.
248      *
249      * @see Log#isDropOnOverflow
250      */

251     public boolean isDropOnOverflow()
252     {
253         return Log.isDropOnOverflow();
254     }
255
256     // }}}
257
// {{{ setDropOnOverflow
258

259     /**
260      * Set whether the callback's application should drop entries when
261      * its log queue overflows.
262      *
263      * @param drop Whether to drop entries on overflow.
264      *
265      * @see Log#setDropOnOverflow
266      */

267     public void setDropOnOverflow(boolean drop)
268     {
269         Log.setDropOnOverflow(drop);
270     }
271
272     // }}}
273
// {{{ getFlushBufferSize
274

275     /**
276      * Get the size of the flush buffer of the callback's application.
277      *
278      * @return The flush buffer size or 0 to indicate no flush buffer.
279      */

280     public int getFlushBufferSize()
281     {
282         return Log.getFlushBufferSize();
283     }
284
285     // }}}
286
// {{{ setFlushBufferSize
287

288     /**
289      * Set the size of the flush buffer of the callback's application. Setting
290      * it to 0 will turn the flush buffer off.
291      *
292      * @param size The size of the flush buffer.
293      */

294     public void setFlushBufferSize(int size)
295     {
296         Log.setFlushBufferSize(size);
297     }
298
299     // }}}
300
// {{{ getFlushTriggerLevel
301

302     /**
303      * Get the level that will trigger a flush of the messages saved in the
304      * flush buffer of the callback's application.
305      *
306      * @return The flush buffer's trigger level.
307      */

308     public int getFlushTriggerLevel()
309     {
310         return Log.getFlushTriggerLevel();
311     }
312
313     // }}}
314
// {{{ setFlushTriggerLevel
315

316     /**
317      * Set the level that will trigger a flush of the messages saved in the
318      * flush buffer of the callback's application.
319      *
320      * @param level The trigger level to set.
321      */

322     public void setFlushTriggerLevel(int level)
323     {
324         Log.setFlushTriggerLevel(level);
325     }
326
327     // }}}
328
// {{{ getPostFlushSize
329

330     /**
331      * Get the number of messages to pass unfiltered through the pre-queue
332      * stage after a flush happened in the callback's application.
333      *
334      * @return The number of messages to pass.
335      */

336     public int getPostFlushSize()
337     {
338         return Log.getPostFlushSize();
339     }
340
341     // }}}
342
// {{{ setPostFlushSize
343

344     /**
345      * Set the number of messages to pass unfiltered through the pre-queue
346      * stage after a flush happened in the callback's application.
347      *
348      * @param size The number of messages to pass.
349      */

350     public void setPostFlushSize(int size)
351     {
352         Log.setPostFlushSize(size);
353     }
354
355     // }}}
356
}
357
Popular Tags