root/trunk/src/java/org/jcoderz/commons/logging/DisplayOptions.java

Revision 1299, 12.8 kB (checked in by amandel, 3 years ago)
  • Log formatter ignores the category field but now outputs the last 9 characters of the thread name. In case of a ordinary log record the the name of the logger thread is used. This might be wrong in certain setups but is correct in many cases. The fawkeZ loggable records the thread name of the thread that created the loggable instance which is the correct thread name in all cases. #58
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1/*
2 * $Id$
3 *
4 * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 *    * Redistributions of source code must retain the above copyright
11 *      notice, this list of conditions and the following disclaimer.
12 *    * Redistributions in binary form must reproduce the above
13 *      copyright notice, this list of conditions and the following
14 *      disclaimer in the documentation and/or other materials
15 *      provided with the distribution.
16 *    * Neither the name of the jCoderZ.org Project nor the names of
17 *      its contributors may be used to endorse or promote products
18 *      derived from this software without specific prior written
19 *      permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33package org.jcoderz.commons.logging;
34
35/**
36 * This class comprises display options, i.e. which fields are to
37 * display with how many details.
38 *
39 */
40public final class DisplayOptions
41      implements Cloneable
42{
43   private boolean mDisplayParameters = true;
44   private boolean mDisplaySolution = true;
45   private boolean mDisplayMethod = false;
46   private boolean mDisplayThreadId = false;
47   private boolean mDisplayNodeId = true;
48   private boolean mDisplayInstanceId = true;
49   private boolean mDisplayBusinessImpact = false;
50   private boolean mDisplayCategory = false;
51   private boolean mDisplayLevel = false;
52   private boolean mDisplayTimestamp = false;
53   private boolean mDisplayRecordNumber = false;
54   private boolean mDisplayClass = false;
55   private boolean mDisplaySymbol = true;
56   private boolean mDisplaySymbolId = true;
57   private boolean mDisplayTrackingNumber = true;
58   private boolean mDisplayStackTrace = true;
59   private boolean mDisplayMessageStackTrace = false;
60   private boolean mDisplayTraceLines = false;
61   private boolean mThreadName = false;
62
63   /**
64    * Sets the flag whether the thread id is displayed.
65    *
66    * @param display If true, thread id is displayed; if false do not display
67    * the thread id.
68    */
69   public void displayThreadId (final boolean display)
70   {
71      mDisplayThreadId = display;
72   }
73
74   /**
75    * Gets the flag whether the thread id is displayed.
76    *
77    * @return true if the thread id is to display; false, else.
78    */
79   public boolean displayThreadId ()
80   {
81      return mDisplayThreadId;
82   }
83
84   /**
85    * Sets the flag whether the node id is displayed.
86    *
87    * @param display If true, node id is displayed; if false do not display
88    * the node id.
89    */
90   public void displayNodeId (final boolean display)
91   {
92      mDisplayNodeId = display;
93   }
94
95   /**
96    * Gets the flag whether the node id is displayed.
97    *
98    * @return true if the node id is to display; false, else.
99    */
100   public boolean displayNodeId ()
101   {
102      return mDisplayNodeId;
103   }
104
105   /**
106    * Sets the flag whether the instance id is displayed.
107    *
108    * @param display If true, instance id is displayed; if false do not display
109    * the instance id.
110    */
111   public void displayInstanceId (final boolean display)
112   {
113      mDisplayInstanceId = display;
114   }
115
116   /**
117    * Gets the flag whether the instance id is displayed.
118    *
119    * @return true if the instance id is to display; false, else.
120    */
121   public boolean displayInstanceId ()
122   {
123      return mDisplayInstanceId;
124   }
125
126   /**
127    * Sets the flag whether the business impact is displayed.
128    *
129    * @param display If true, business impact is displayed; if false do not
130    * display the business impact.
131    */
132   public void displayBusinessImpact (final boolean display)
133   {
134      mDisplayBusinessImpact = display;
135   }
136
137   /**
138    * Gets the flag whether the business impact is displayed.
139    *
140    * @return true if the business impact is to display; false, else.
141    */
142   public boolean displayBusinessImpact ()
143   {
144      return mDisplayBusinessImpact;
145   }
146
147   /**
148    * Sets the flag whether the category is displayed.
149    *
150    * @param display If true, category is displayed; if false do not
151    * display the category.
152    */
153   public void displayCategory (final boolean display)
154   {
155      mDisplayCategory = display;
156   }
157
158   /**
159    * Gets the flag whether the category is displayed.
160    *
161    * @return true if the category is to display; false, else.
162    */
163   public boolean displayCategory ()
164   {
165      return mDisplayCategory;
166   }
167
168   /**
169    * Sets the flag whether the thread name is displayed.
170    *
171    * @param display If true, the thread name is displayed; if false do not
172    * display the thread name.
173    */
174   public void displayThreadName (final boolean display)
175   {
176      mThreadName = display;
177   }
178
179   /**
180    * Sets the flag whether the thread name should be displayed.
181    * @return true, the thread name is displayed; if false do not
182    * display the thread name.
183    */
184   public boolean displayThreadName ()
185   {
186      return mThreadName;
187   }
188
189   /**
190    * Sets the flag whether the logger level / severity is displayed.
191    *
192    * @param display If true, logger level is displayed; if false do not
193    * display the logger level.
194    */
195   public void displayLoggerLevel (final boolean display)
196   {
197      mDisplayLevel = display;
198   }
199
200   /**
201    * Gets the flag whether the logger level is displayed.
202    *
203    * @return true if the logger level is to display; false, else.
204    */
205   public boolean displayLoggerLevel ()
206   {
207      return mDisplayLevel;
208   }
209
210   /**
211    * Sets the flag whether the timestamp is displayed.
212    *
213    * @param display If true, timestamp is displayed; if false do not
214    * display the timestamp.
215    */
216   public void displayTimestamp (final boolean display)
217   {
218      mDisplayTimestamp = display;
219   }
220
221   /**
222    * Gets the flag whether the timestamp is displayed.
223    *
224    * @return true if the timestamp is to display; false, else.
225    */
226   public boolean displayTimestamp ()
227   {
228      return mDisplayTimestamp;
229   }
230
231   /**
232    * Sets the flag whether the record number of a log file record is displayed.
233    *
234    * @param display If true, record number is displayed; if false do not
235    * display the record number.
236    */
237   public void displayRecordNumber (final boolean display)
238   {
239      mDisplayRecordNumber = display;
240   }
241
242   /**
243    * Gets the flag whether the record number is displayed.
244    *
245    * @return true if the record number is to display; false, else.
246    */
247   public boolean displayRecordNumber ()
248   {
249      return mDisplayRecordNumber;
250   }
251
252   /**
253    * Sets the flag whether the source class, where the message was logged, is
254    * displayed.
255    *
256    * @param display If true, source class is displayed; if false do not
257    * display the source class.
258    */
259   public void displaySourceClass (final boolean display)
260   {
261      mDisplayClass = display;
262   }
263
264   /**
265    * Gets the flag whether the source class name is displayed.
266    *
267    * @return true if the source class name is to display; false, else.
268    */
269   public boolean displaySourceClass ()
270   {
271      return mDisplayClass;
272   }
273
274   /**
275    * Sets the flag whether the source method, where the message was logged, is
276    * displayed.
277    *
278    * @param display If true, source method is displayed; if false do not
279    * display the source method.
280    */
281   public void displaySourceMethod (final boolean display)
282   {
283      mDisplayMethod = display;
284   }
285
286   /**
287    * Gets the flag whether the source method name is displayed.
288    *
289    * @return true if the source method name is to display; false, else.
290    */
291   public boolean displaySourceMethod ()
292   {
293      return mDisplayMethod;
294   }
295
296   /**
297    * Sets the flag whether the possible solution for a message is displayed.
298    *
299    * @param display If true, solution is displayed; if false do not
300    * display the solution.
301    */
302   public void displaySolution (final boolean display)
303   {
304      mDisplaySolution = display;
305   }
306
307   /**
308    * Gets the flag whether the possible solution is displayed.
309    *
310    * @return true if the solution is to display; false, else.
311    */
312   public boolean displaySolution ()
313   {
314      return mDisplaySolution;
315   }
316
317   /**
318    * Sets the flag whether the parameters for a message are displayed.
319    *
320    * @param display If true, parameters are displayed; if false do not
321    * display the parameters.
322    */
323   public void displayParameters (final boolean display)
324   {
325      mDisplayParameters = display;
326   }
327
328   /**
329    * Gets the flag whether the parameters are displayed.
330    *
331    * @return true if the parameters are to display; false, else.
332    */
333   public boolean displayParameters ()
334   {
335      return mDisplayParameters;
336   }
337
338   /**
339    * Sets the flag whether the symbol is displayed.
340    *
341    * @param display If true, the symbol is displayed; if false do not
342    * display the symbol.
343    */
344   public void displaySymbol (final boolean display)
345   {
346      mDisplaySymbol = display;
347   }
348
349   /**
350    * Gets the flag whether the symbol is displayed.
351    *
352    * @return true if the symbol is to display; false, else.
353    */
354   public boolean displaySymbol ()
355   {
356      return mDisplaySymbol;
357   }
358
359   /**
360    * Sets the flag whether the symbol id is displayed.
361    *
362    * @param display If true, the symbol id is displayed; if false do not
363    * display the symbol id.
364    */
365   public void displaySymbolId (final boolean display)
366   {
367      mDisplaySymbolId = display;
368   }
369
370   /**
371    * Gets the flag whether the symbol id is displayed.
372    *
373    * @return true if the symbol id is to display; false, else.
374    */
375   public boolean displaySymbolId ()
376   {
377      return mDisplaySymbolId;
378   }
379
380   /**
381    * Sets the flag whether the sequence of tracking numbers is displayed.
382    *
383    * @param display If true, the sequence of tracking numbers is displayed;
384    * if false do not display the sequence of tracking numbers.
385    */
386   public void displayTrackingNumber (final boolean display)
387   {
388      mDisplayTrackingNumber = display;
389   }
390
391   /**
392    * Gets the flag whether the sequence of tracking numbers is displayed.
393    *
394    * @return true if the sequence of tracking numbers is to display;
395    * false, else.
396    */
397   public boolean displayTrackingNumber ()
398   {
399      return mDisplayTrackingNumber;
400   }
401
402   /**
403    * Sets the flag whether the stack trace of an exception is displayed.
404    *
405    * @param display If true, the stacktrace of an exception is displayed;
406    * if false do not display an exception's stacktrace.
407    */
408   public void displayStackTrace (final boolean display)
409   {
410      mDisplayStackTrace = display;
411   }
412
413   /**
414    * Gets the flag whether an exception's stacktrace is displayed.
415    *
416    * @return true if the stacktrace of an exception is to display; false, else.
417    */
418   public boolean displayStackTrace ()
419   {
420      return mDisplayStackTrace;
421   }
422
423   /**
424    * Sets the flag whether the stack trace of a log message is displayed.
425    *
426    * @param display If true, the stacktrace of a log message is displayed;
427    * if false do not display a log message's stacktrace.
428    */
429   public void displayMessageStackTrace (final boolean display)
430   {
431      mDisplayMessageStackTrace = display;
432   }
433
434   /**
435    * Gets the flag whether a log message's stacktrace is displayed.
436    *
437    * @return true if the stacktrace of an log message is to display;
438    * false, else.
439    */
440   public boolean displayMessageStackTrace ()
441   {
442      return mDisplayMessageStackTrace;
443   }
444
445   /**
446    * Sets the flag whether standard trace logs are displayed, i.e. undeclared
447    * log messages, which are generated by standard logger api calls.
448    *
449    * @param display If true, standard trace logs are displayed;
450    * if false do not display standard trace logs.
451    */
452   public void displayTraceLines (final boolean display)
453   {
454      mDisplayTraceLines = display;
455   }
456
457   /**
458    * Gets the flag whether standard trace logs are displayed, i.e. undeclared
459    * log messages, which are generated by standard logger api calls.
460    *
461    * @return true if trace logs are to display; false, else.
462    */
463   public boolean displayTraceLines ()
464   {
465      return mDisplayTraceLines;
466   }
467
468   /** {@inheritDoc} */
469   public Object clone ()
470       throws CloneNotSupportedException
471   {
472       return super.clone();
473   }
474}
Note: See TracBrowser for help on using the browser.