1 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
ajm |
1.2 |
package uk.ac.ukc.iscream.core; |
3 |
tdb |
1.1 |
|
4 |
|
|
//---IMPORTS--- |
5 |
|
|
import org.omg.CORBA.*; |
6 |
|
|
import org.omg.PortableServer.*; |
7 |
|
|
|
8 |
|
|
/** |
9 |
|
|
* The ScreenLoggerServant is an implementation of the Logger defined |
10 |
|
|
* in the IDL interface. It's only purpose is to simply print all the |
11 |
|
|
* logging information it receives to the screen. |
12 |
|
|
* |
13 |
ajm |
1.2 |
* @author $Author: tdb1 $ |
14 |
|
|
* @version $Id: LoggerServant.java,v 1.1 2000/11/20 18:37:57 tdb1 Exp $ |
15 |
tdb |
1.1 |
*/ |
16 |
|
|
class LoggerServant extends LoggerPOA { |
17 |
|
|
|
18 |
|
|
//---FINAL ATTRIBUTES--- |
19 |
|
|
|
20 |
|
|
/** |
21 |
|
|
* The current CVS revision of this class |
22 |
|
|
*/ |
23 |
|
|
public final String REVISION = "$Revision: 1.1 $"; |
24 |
|
|
|
25 |
|
|
//---STATIC METHODS--- |
26 |
|
|
|
27 |
|
|
//---CONSTRUCTORS--- |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* Creates a new LoggerServant. |
31 |
|
|
* |
32 |
|
|
* @param logger a reference to the LoggerImpl this will use |
33 |
|
|
*/ |
34 |
|
|
public LoggerServant(LoggerImpl logger) { |
35 |
|
|
_logger = logger; |
36 |
|
|
_verbosityLevel = Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.Verbosity")); |
37 |
|
|
write(this.toString(), Logger.SYSINIT, "started"); |
38 |
|
|
write(this.toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
//---PUBLIC METHODS--- |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* The write() method simply passes the call on to it's local |
45 |
|
|
* LoggerImpl object. |
46 |
|
|
* |
47 |
|
|
* @param source A string representation of the calling object. |
48 |
|
|
* @param verbosity the verbosity of this message |
49 |
|
|
* @param message The text to be logged. |
50 |
|
|
*/ |
51 |
|
|
public void write(String source, int verbosity, String message) { |
52 |
|
|
_logger.write(source, verbosity, message); |
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 case returns the information from the LoggerImpl, although maybe |
60 |
|
|
* it should be merged with this somehow ? |
61 |
|
|
* |
62 |
|
|
* @return the name of this class and its CVS revision |
63 |
|
|
*/ |
64 |
|
|
public String toString() { |
65 |
|
|
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
66 |
|
|
} |
67 |
|
|
//---PRIVATE METHODS--- |
68 |
|
|
|
69 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
70 |
|
|
|
71 |
|
|
//---ATTRIBUTES--- |
72 |
|
|
|
73 |
|
|
/** |
74 |
|
|
* The verbosity level of this instance |
75 |
|
|
*/ |
76 |
|
|
private int _verbosityLevel; |
77 |
|
|
|
78 |
|
|
/** |
79 |
|
|
* The actual Logger used by this instance |
80 |
|
|
*/ |
81 |
|
|
private LoggerImpl _logger; |
82 |
|
|
|
83 |
|
|
//---STATIC ATTRIBUTES--- |
84 |
|
|
|
85 |
|
|
} |