33 |
|
* Creates a new ScreenLoggerServant. |
34 |
|
*/ |
35 |
|
public ScreenLogger() { |
36 |
– |
_verbosityLevel = Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.Verbosity")); |
36 |
|
write(toString(), Logger.SYSINIT, "started"); |
38 |
– |
write(toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel); |
37 |
|
} |
38 |
|
|
39 |
|
//---PUBLIC METHODS--- |
50 |
|
* @param verbosity the verbosity of this message |
51 |
|
* @param message The text to be logged. |
52 |
|
*/ |
53 |
< |
public synchronized void write(String source, int verbosity, String message) { |
54 |
< |
if (verbosity <= _verbosityLevel) { |
57 |
< |
String line = formatLogLine(source, message); |
58 |
< |
System.out.println(line); |
59 |
< |
} |
53 |
> |
public synchronized void write(String line, int verbosity) {; |
54 |
> |
System.out.println(line); |
55 |
|
} |
56 |
|
|
57 |
|
/** |
72 |
|
|
73 |
|
//---PRIVATE METHODS--- |
74 |
|
|
75 |
< |
/** |
76 |
< |
* This method generates a nicely formatted line for the log, |
82 |
< |
* including the date/time and the source of the message. The date |
83 |
< |
* and time are formatted using the DateFormat class, and the source |
84 |
< |
* class is formatted using the toString() method found in every |
85 |
< |
* source file. This is then prepended to the message and returned. |
86 |
< |
* |
87 |
< |
* @param source A string representation of the calling object. |
88 |
< |
* @param message The message to be logged. |
89 |
< |
* @return The string to be written to the log. |
90 |
< |
*/ |
91 |
< |
private String formatLogLine(String source, String message){ |
92 |
< |
String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date()); |
93 |
< |
return "[" + date + "] " + source + ": " + message; |
75 |
> |
private void write(String source, int verbosity, String message) { |
76 |
> |
write(FormatName.formatLogLine(source, verbosity, message), verbosity); |
77 |
|
} |
78 |
|
|
79 |
|
//---ACCESSOR/MUTATOR METHODS--- |
80 |
|
|
81 |
|
//---ATTRIBUTES--- |
99 |
– |
|
100 |
– |
/** |
101 |
– |
* The verbosity level of this instance |
102 |
– |
*/ |
103 |
– |
private int _verbosityLevel; |
82 |
|
|
83 |
|
/** |
84 |
|
* This is the friendly identifier of the |