1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.core; |
2 |
> |
package uk.org.iscream.core; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.util.*; |
5 |
> |
import uk.org.iscream.util.*; |
6 |
|
|
7 |
|
/** |
8 |
|
* The LoggerServant is an implementation of the Logger defined |
39 |
|
*/ |
40 |
|
public LoggerServant(LoggerImpl logger) { |
41 |
|
_logger = logger; |
42 |
< |
_verbosityLevel = Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.Verbosity")); |
42 |
> |
_verbosityLevel = Integer.parseInt(System.getProperty("uk.org.iscream.Verbosity")); |
43 |
|
write(toString(), Logger.SYSINIT, "started"); |
44 |
|
write(toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel); |
45 |
|
} |
47 |
|
//---PUBLIC METHODS--- |
48 |
|
|
49 |
|
/** |
50 |
< |
* The write() method simply passes the call on to it's local |
51 |
< |
* LoggerImpl object. |
52 |
< |
* |
53 |
< |
* Note the "source" is prepended with the name of the verbosity level. |
50 |
> |
* The write() method takes a source, verbosity level and |
51 |
> |
* message, and formats them using an external line |
52 |
> |
* formatting method. This line is then given to the logger |
53 |
> |
* to be written. Note that checking of the level is carried |
54 |
> |
* out here. |
55 |
|
* |
56 |
|
* @param source A string representation of the calling object. |
57 |
|
* @param verbosity the verbosity of this message |
58 |
|
* @param message The text to be logged. |
59 |
|
*/ |
60 |
|
public void write(String source, int verbosity, String message) { |
61 |
< |
_logger.write("[" + VERBOSITY_NAMES[verbosity] + "] " + source, verbosity, message); |
61 |
> |
if (verbosity <= _verbosityLevel) { |
62 |
> |
_logger.write(FormatName.formatLogLine(source, verbosity, message), verbosity); |
63 |
> |
} |
64 |
|
} |
65 |
|
|
66 |
|
/** |
67 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
68 |
|
* method to provide clean logging (every class should have this). |
69 |
|
* |
70 |
< |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
70 |
> |
* This uses the uk.org.iscream.util.FormatName class |
71 |
|
* to format the toString() |
72 |
|
* |
73 |
|
* @return the name of this class and its CVS revision |