ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/core/LoggerServant.java
Revision: 1.10
Committed: Tue May 29 17:02:34 2001 UTC (22 years, 11 months ago) by tdb
Branch: MAIN
Branch point for: SERVER_PIRCBOT
Changes since 1.9: +6 -6 lines
Log Message:
Major change in the java package naming. This has been held off for some time
now, but it really needed doing. The future packaging of all i-scream products
will be;

uk.org.iscream.<product>.<subpart>.*

In the case of the central monitoring system server this will be;

uk.org.iscream.cms.server.*

The whole server has been changed to follow this structure, and tested to a
smallish extent. Further changes in other parts of the CMS will follow.

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2 tdb 1.10 package uk.org.iscream.cms.server.core;
3 tdb 1.1
4     //---IMPORTS---
5 tdb 1.10 import uk.org.iscream.cms.server.util.*;
6 tdb 1.1
7     /**
8 ajm 1.4 * The LoggerServant is an implementation of the Logger defined
9     * in the IDL interface. Allows classes to send logging information
10     * over CORBA to a local implementation of the LoggerImpl interface.
11 tdb 1.1 *
12 tdb 1.7 * @author $Author: tdb1 $
13 tdb 1.10 * @version $Id: LoggerServant.java,v 1.9 2001/03/14 23:25:29 tdb1 Exp $
14 tdb 1.1 */
15     class LoggerServant extends LoggerPOA {
16    
17     //---FINAL ATTRIBUTES---
18    
19     /**
20     * The current CVS revision of this class
21     */
22 tdb 1.10 public final String REVISION = "$Revision: 1.9 $";
23 ajm 1.4
24     /**
25     * An array of names of verbosity levels.
26     * Thus logging messages are now "classed" by the level"
27     * This string is prepended to the "source" of a logging message.
28     */
29     public final static String[] VERBOSITY_NAMES = {"FATAL", "ERROR", "WARNING", "SYSMSG", "SYSINIT", "DEBUG"};
30 tdb 1.1
31     //---STATIC METHODS---
32    
33     //---CONSTRUCTORS---
34    
35     /**
36     * Creates a new LoggerServant.
37     *
38     * @param logger a reference to the LoggerImpl this will use
39     */
40     public LoggerServant(LoggerImpl logger) {
41     _logger = logger;
42 tdb 1.10 _verbosityLevel = Integer.parseInt(System.getProperty("uk.org.iscream.cms.server.Verbosity"));
43 ajm 1.3 write(toString(), Logger.SYSINIT, "started");
44     write(toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel);
45 tdb 1.1 }
46    
47     //---PUBLIC METHODS---
48    
49     /**
50 tdb 1.8 * The write() method takes a source, verbosity level and
51 tdb 1.7 * 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 tdb 1.1 *
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 tdb 1.6 if (verbosity <= _verbosityLevel) {
62     _logger.write(FormatName.formatLogLine(source, verbosity, message), verbosity);
63     }
64 tdb 1.1 }
65    
66     /**
67     * Overrides the {@link java.lang.Object#toString() Object.toString()}
68     * method to provide clean logging (every class should have this).
69 ajm 1.3 *
70 tdb 1.10 * This uses the uk.org.iscream.cms.server.util.FormatName class
71 ajm 1.3 * to format the toString()
72     *
73 tdb 1.1 * @return the name of this class and its CVS revision
74     */
75     public String toString() {
76 ajm 1.3 return FormatName.getName(
77     _name,
78     getClass().getName(),
79     REVISION);
80 tdb 1.1 }
81 ajm 1.3
82 tdb 1.1 //---PRIVATE METHODS---
83    
84     //---ACCESSOR/MUTATOR METHODS---
85    
86     //---ATTRIBUTES---
87    
88     /**
89     * The verbosity level of this instance
90     */
91     private int _verbosityLevel;
92    
93     /**
94     * The actual Logger used by this instance
95     */
96     private LoggerImpl _logger;
97 ajm 1.3
98     /**
99     * This is the friendly identifier of the
100     * component this class is running in.
101     * eg, a Filter may be called "filter1",
102     * If this class does not have an owning
103     * component, a name from the configuration
104     * can be placed here. This name could also
105     * be changed to null for utility classes.
106     */
107     private String _name = Core.NAME;
108 tdb 1.1
109     //---STATIC ATTRIBUTES---
110    
111     }