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/loggers/MultiLogger.java
Revision: 1.5
Committed: Sun Feb 25 20:34:16 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.4: +10 -6 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

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.core.loggers;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6 import uk.ac.ukc.iscream.core.*;
7 import java.io.IOException;
8
9 /**
10 * The MultiLogger is just a gateway to both the ScreenLogger
11 * and the FileLogger.
12 *
13 * @author $Author: tdb1 $
14 * @version $Id: MultiLogger.java,v 1.4 2001/01/22 21:29:17 tdb1 Exp $
15 */
16 public class MultiLogger implements LoggerImpl {
17
18 //---FINAL ATTRIBUTES---
19
20 /**
21 * The current CVS revision of this class
22 */
23 public final String REVISION = "$Revision: 1.4 $";
24
25 //---STATIC METHODS---
26
27 //---CONSTRUCTORS---
28
29 /**
30 * Creates a new MultiLogger.
31 */
32 public MultiLogger() throws IOException {
33 _screenlog = new ScreenLogger();
34 _filelog = new FileLogger();
35 write(toString(), Logger.SYSINIT, "started");
36 }
37
38 //---PUBLIC METHODS---
39
40 /**
41 * The write() method takes a message, formats it using the
42 * formatLogLine() method, and then outputs it to the screen
43 * using System.out.println(). The source is usually the
44 * calling object, referenced by `this'. The method has been
45 * made synchronized to avoid it being called by two different
46 * objects and the output ending up merged on the screen.
47 *
48 * @param source A string representation of the calling object.
49 * @param verbosity the verbosity of this message
50 * @param message The text to be logged.
51 */
52 public synchronized void write(String line, int verbosity) {
53 _screenlog.write(line, verbosity);
54 _filelog.write(line, verbosity);
55 }
56
57 /**
58 * Overrides the {@link java.lang.Object#toString() Object.toString()}
59 * method to provide clean logging (every class should have this).
60 *
61 * This uses the uk.ac.ukc.iscream.util.FormatName class
62 * to format the toString()
63 *
64 * @return the name of this class and its CVS revision
65 */
66 public String toString() {
67 return FormatName.getName(
68 _name,
69 getClass().getName(),
70 REVISION);
71 }
72
73 //---PRIVATE METHODS---
74
75 private void write(String source, int verbosity, String message) {
76 write(FormatName.formatLogLine(source, verbosity, message), verbosity);
77 }
78
79 //---ACCESSOR/MUTATOR METHODS---
80
81 //---ATTRIBUTES---
82
83 /**
84 * A reference to the ScreenLogger we'll use
85 */
86 private LoggerImpl _screenlog;
87
88 /**
89 * A reference to the FileLogger we'll use
90 */
91 private LoggerImpl _filelog;
92
93 /**
94 * This is the friendly identifier of the
95 * component this class is running in.
96 * eg, a Filter may be called "filter1",
97 * If this class does not have an owning
98 * component, a name from the configuration
99 * can be placed here. This name could also
100 * be changed to null for utility classes.
101 */
102 private String _name = Core.NAME;
103
104 //---STATIC ATTRIBUTES---
105
106 }