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.4
Committed: Mon Jan 22 21:29:17 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.3: +3 -3 lines
Log Message:
Can't instantiate unless the class is public.

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: ajm4 $
14 * @version $Id: MultiLogger.java,v 1.3 2000/12/12 18:28:19 ajm4 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.3 $";
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 source, int verbosity, String message) {
53 _screenlog.write(source, verbosity, message);
54 _filelog.write(source, verbosity, message);
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 //---ACCESSOR/MUTATOR METHODS---
76
77 //---ATTRIBUTES---
78
79 /**
80 * A reference to the ScreenLogger we'll use
81 */
82 private LoggerImpl _screenlog;
83
84 /**
85 * A reference to the FileLogger we'll use
86 */
87 private LoggerImpl _filelog;
88
89 /**
90 * This is the friendly identifier of the
91 * component this class is running in.
92 * eg, a Filter may be called "filter1",
93 * If this class does not have an owning
94 * component, a name from the configuration
95 * can be placed here. This name could also
96 * be changed to null for utility classes.
97 */
98 private String _name = Core.NAME;
99
100 //---STATIC ATTRIBUTES---
101
102 }