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.6
Committed: Sun Feb 25 20:34:14 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.5: +5 -3 lines
Log Message:
Big change in the logging structure. The line is now generated in an external
class, FormatName (in the util package), and the verbosity checking is carried
out in the LoggerServant instead of each logger.
This change was made to try and have behaviour in one place, rather than in each
individual logger.

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2 ajm 1.2 package uk.ac.ukc.iscream.core;
3 tdb 1.1
4     //---IMPORTS---
5 ajm 1.3 import uk.ac.ukc.iscream.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 ajm 1.3 * @author $Author: ajm4 $
13 tdb 1.6 * @version $Id: LoggerServant.java,v 1.5 2001/02/23 19:02:55 ajm4 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.6 public final String REVISION = "$Revision: 1.5 $";
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     _verbosityLevel = Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.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     * The write() method simply passes the call on to it's local
51     * LoggerImpl object.
52 ajm 1.4 *
53     * Note the "source" is prepended with the name of the verbosity level.
54 tdb 1.1 *
55     * @param source A string representation of the calling object.
56     * @param verbosity the verbosity of this message
57     * @param message The text to be logged.
58     */
59     public void write(String source, int verbosity, String message) {
60 tdb 1.6 if (verbosity <= _verbosityLevel) {
61     _logger.write(FormatName.formatLogLine(source, verbosity, message), verbosity);
62     }
63 tdb 1.1 }
64    
65     /**
66     * Overrides the {@link java.lang.Object#toString() Object.toString()}
67     * method to provide clean logging (every class should have this).
68 ajm 1.3 *
69     * This uses the uk.ac.ukc.iscream.util.FormatName class
70     * to format the toString()
71     *
72 tdb 1.1 * @return the name of this class and its CVS revision
73     */
74     public String toString() {
75 ajm 1.3 return FormatName.getName(
76     _name,
77     getClass().getName(),
78     REVISION);
79 tdb 1.1 }
80 ajm 1.3
81 tdb 1.1 //---PRIVATE METHODS---
82    
83     //---ACCESSOR/MUTATOR METHODS---
84    
85     //---ATTRIBUTES---
86    
87     /**
88     * The verbosity level of this instance
89     */
90     private int _verbosityLevel;
91    
92     /**
93     * The actual Logger used by this instance
94     */
95     private LoggerImpl _logger;
96 ajm 1.3
97     /**
98     * This is the friendly identifier of the
99     * component this class is running in.
100     * eg, a Filter may be called "filter1",
101     * If this class does not have an owning
102     * component, a name from the configuration
103     * can be placed here. This name could also
104     * be changed to null for utility classes.
105     */
106     private String _name = Core.NAME;
107 tdb 1.1
108     //---STATIC ATTRIBUTES---
109    
110     }