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.9
Committed: Sat May 18 18:16:01 2002 UTC (22 years ago) by tdb
Branch: MAIN
Changes since 1.8: +22 -3 lines
Log Message:
i-scream is now licensed under the GPL. I've added the GPL headers to every
source file, and put a full copy of the license in the appropriate places.
I think I've covered everything. This is going to be a mad commit ;)

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * Copyright (C) 2000-2002 i-scream
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 //---PACKAGE DECLARATION---
21 package uk.org.iscream.cms.server.core.loggers;
22
23 //---IMPORTS---
24 import uk.org.iscream.cms.server.util.*;
25 import uk.org.iscream.cms.server.core.*;
26 import java.io.IOException;
27
28 /**
29 * The MultiLogger is just a gateway to both the ScreenLogger
30 * and the FileLogger.
31 *
32 * @author $Author: tdb $
33 * @version $Id: MultiLogger.java,v 1.8 2001/05/29 17:02:35 tdb Exp $
34 */
35 public class MultiLogger implements LoggerImpl {
36
37 //---FINAL ATTRIBUTES---
38
39 /**
40 * The current CVS revision of this class
41 */
42 public final String REVISION = "$Revision: 1.8 $";
43
44 //---STATIC METHODS---
45
46 //---CONSTRUCTORS---
47
48 /**
49 * Creates a new MultiLogger.
50 */
51 public MultiLogger() throws IOException {
52 _screenlog = new ScreenLogger();
53 _filelog = new FileLogger();
54 write(toString(), Logger.SYSINIT, "started");
55 }
56
57 //---PUBLIC METHODS---
58
59 /**
60 * The write() method takes a line of text, pre-formatted
61 * and outputs it using a method defined by the actual
62 * implementation. The verbosity is given in case the
63 * implementation wishes to utilise it in the layout -
64 * eg. a different colour or font.
65 *
66 * This instance passes the message on to a ScreenLogger
67 * and a FileLogger.
68 *
69 * @param line A line of formatted text to be logged
70 * @param verbosity the verbosity of this message
71 */
72 public synchronized void write(String line, int verbosity) {
73 _screenlog.write(line, verbosity);
74 _filelog.write(line, verbosity);
75 }
76
77 /**
78 * Overrides the {@link java.lang.Object#toString() Object.toString()}
79 * method to provide clean logging (every class should have this).
80 *
81 * This uses the uk.org.iscream.cms.server.util.FormatName class
82 * to format the toString()
83 *
84 * @return the name of this class and its CVS revision
85 */
86 public String toString() {
87 return FormatName.getName(
88 _name,
89 getClass().getName(),
90 REVISION);
91 }
92
93 //---PRIVATE METHODS---
94
95 /**
96 * This method is provided if this class wishes to log
97 * a message itself.
98 *
99 * @param source A String representation of the source
100 * @param verbosity the verbosity of this message
101 * @param message The message to log
102 */
103 private void write(String source, int verbosity, String message) {
104 write(FormatName.formatLogLine(source, verbosity, message), verbosity);
105 }
106
107 //---ACCESSOR/MUTATOR METHODS---
108
109 //---ATTRIBUTES---
110
111 /**
112 * A reference to the ScreenLogger we'll use
113 */
114 private LoggerImpl _screenlog;
115
116 /**
117 * A reference to the FileLogger we'll use
118 */
119 private LoggerImpl _filelog;
120
121 /**
122 * This is the friendly identifier of the
123 * component this class is running in.
124 * eg, a Filter may be called "filter1",
125 * If this class does not have an owning
126 * component, a name from the configuration
127 * can be placed here. This name could also
128 * be changed to null for utility classes.
129 */
130 private String _name = Core.NAME;
131
132 //---STATIC ATTRIBUTES---
133
134 }