1 |
//---PACKAGE DECLARATION--- |
2 |
//package uk.org.iscream.core.loggers; |
3 |
|
4 |
//---IMPORTS--- |
5 |
import java.util.Date; |
6 |
import java.text.DateFormat; |
7 |
import java.util.Locale; |
8 |
|
9 |
/** |
10 |
* The ScreenLogger is an implementation of the LoggerImpl defined |
11 |
* in the associated interface. It's only purpose is to simply print |
12 |
* all the logging information it receives to the screen. |
13 |
* |
14 |
* @author $Author: tdb1 $ |
15 |
* @version $Id: ScreenLogger.java,v 1.6 2001/03/14 23:25:29 tdb1 Exp $ |
16 |
*/ |
17 |
public class ScreenLogger implements LoggerImpl { |
18 |
|
19 |
//---FINAL ATTRIBUTES--- |
20 |
|
21 |
/** |
22 |
* The current CVS revision of this class |
23 |
*/ |
24 |
public final String REVISION = "$Revision: 1.6 $"; |
25 |
|
26 |
//---STATIC METHODS--- |
27 |
|
28 |
//---CONSTRUCTORS--- |
29 |
|
30 |
/** |
31 |
* Creates a new ScreenLoggerServant. |
32 |
*/ |
33 |
public ScreenLogger() { |
34 |
write(toString(), Logger.SYSINIT, "created"); |
35 |
} |
36 |
|
37 |
//---PUBLIC METHODS--- |
38 |
|
39 |
/** |
40 |
* The write() method takes a line of text, pre-formatted |
41 |
* and outputs it using a method defined by the actual |
42 |
* implementation. The verbosity is given in case the |
43 |
* implementation wishes to utilise it in the layout - |
44 |
* eg. a different colour or font. |
45 |
* |
46 |
* This instance simply prints the message to the screen. |
47 |
* |
48 |
* @param line A line of formatted text to be logged |
49 |
* @param verbosity the verbosity of this message |
50 |
*/ |
51 |
public synchronized void write(String line, int verbosity) {; |
52 |
System.out.println(line); |
53 |
} |
54 |
|
55 |
/** |
56 |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
57 |
* method to provide clean logging (every class should have this). |
58 |
* |
59 |
* This uses the uk.org.iscream.util.FormatName class |
60 |
* to format the toString() |
61 |
* |
62 |
* @return the name of this class and its CVS revision |
63 |
*/ |
64 |
public String toString() { |
65 |
return FormatName.getName( |
66 |
_name, |
67 |
getClass().getName(), |
68 |
REVISION); |
69 |
} |
70 |
|
71 |
//---PRIVATE/PROTECTED METHODS--- |
72 |
|
73 |
/** |
74 |
* This method is provided if this class wishes to log |
75 |
* a message itself. |
76 |
* |
77 |
* @param source A String representation of the source |
78 |
* @param verbosity the verbosity of this message |
79 |
* @param message The message to log |
80 |
*/ |
81 |
private void write(String source, int verbosity, String message) { |
82 |
write(FormatName.formatLogLine(source, verbosity, message), verbosity); |
83 |
} |
84 |
|
85 |
//---ACCESSOR/MUTATOR METHODS--- |
86 |
|
87 |
//---ATTRIBUTES--- |
88 |
|
89 |
/** |
90 |
* This is the friendly identifier of the |
91 |
* component this class is running in. |
92 |
* eg, a Filter may be called "filter1", |
93 |
* If this class does not have an owning |
94 |
* component, a name from the configuration |
95 |
* can be placed here. This name could also |
96 |
* be changed to null for utility classes. |
97 |
*/ |
98 |
private String _name = "ScreenLogger"; |
99 |
|
100 |
//---STATIC ATTRIBUTES--- |
101 |
|
102 |
} |