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.4
Committed: Fri Feb 23 18:59:43 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.3: +15 -6 lines
Log Message:
now prepends the name of the verbosity level to the source of the logging message
better class description

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.core;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6
7 /**
8 * 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 *
12 * @author $Author: ajm4 $
13 * @version $Id: LoggerServant.java,v 1.3 2000/12/12 18:26:52 ajm4 Exp $
14 */
15 class LoggerServant extends LoggerPOA {
16
17 //---FINAL ATTRIBUTES---
18
19 /**
20 * The current CVS revision of this class
21 */
22 public final String REVISION = "$Revision: 1.3 $";
23
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
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 write(toString(), Logger.SYSINIT, "started");
44 write(toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel);
45 }
46
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.
54 *
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 _logger.write("|" + VERBOSITY_NAMES[verbosity] + "|" source, verbosity, message);
61 }
62
63 /**
64 * Overrides the {@link java.lang.Object#toString() Object.toString()}
65 * method to provide clean logging (every class should have this).
66 *
67 * This uses the uk.ac.ukc.iscream.util.FormatName class
68 * to format the toString()
69 *
70 * @return the name of this class and its CVS revision
71 */
72 public String toString() {
73 return FormatName.getName(
74 _name,
75 getClass().getName(),
76 REVISION);
77 }
78
79 //---PRIVATE METHODS---
80
81 //---ACCESSOR/MUTATOR METHODS---
82
83 //---ATTRIBUTES---
84
85 /**
86 * The verbosity level of this instance
87 */
88 private int _verbosityLevel;
89
90 /**
91 * The actual Logger used by this instance
92 */
93 private LoggerImpl _logger;
94
95 /**
96 * This is the friendly identifier of the
97 * component this class is running in.
98 * eg, a Filter may be called "filter1",
99 * If this class does not have an owning
100 * component, a name from the configuration
101 * can be placed here. This name could also
102 * be changed to null for utility classes.
103 */
104 private String _name = Core.NAME;
105
106 //---STATIC ATTRIBUTES---
107
108 }