1 |
tdb |
1.8 |
/* |
2 |
|
|
* i-scream central monitoring system |
3 |
tdb |
1.11 |
* http://www.i-scream.org |
4 |
tdb |
1.8 |
* Copyright (C) 2000-2002 i-scream |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
22 |
tdb |
1.7 |
package uk.org.iscream.cms.server.core.loggers; |
23 |
tdb |
1.1 |
|
24 |
|
|
//---IMPORTS--- |
25 |
tdb |
1.10 |
import uk.org.iscream.cms.util.*; |
26 |
tdb |
1.7 |
import uk.org.iscream.cms.server.core.*; |
27 |
tdb |
1.1 |
import java.util.Date; |
28 |
|
|
import java.text.DateFormat; |
29 |
|
|
import java.util.Locale; |
30 |
|
|
|
31 |
|
|
/** |
32 |
|
|
* The ScreenLogger is an implementation of the LoggerImpl defined |
33 |
|
|
* in the associated interface. It's only purpose is to simply print |
34 |
|
|
* all the logging information it receives to the screen. |
35 |
|
|
* |
36 |
tdb |
1.8 |
* @author $Author: tdb $ |
37 |
tdb |
1.11 |
* @version $Id: ScreenLogger.java,v 1.10 2003/02/05 16:43:47 tdb Exp $ |
38 |
tdb |
1.1 |
*/ |
39 |
ajm |
1.2 |
public class ScreenLogger implements LoggerImpl { |
40 |
tdb |
1.1 |
|
41 |
|
|
//---FINAL ATTRIBUTES--- |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* The current CVS revision of this class |
45 |
|
|
*/ |
46 |
tdb |
1.11 |
public final String REVISION = "$Revision: 1.10 $"; |
47 |
tdb |
1.1 |
|
48 |
|
|
//---STATIC METHODS--- |
49 |
|
|
|
50 |
|
|
//---CONSTRUCTORS--- |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* Creates a new ScreenLoggerServant. |
54 |
|
|
*/ |
55 |
|
|
public ScreenLogger() { |
56 |
ajm |
1.3 |
write(toString(), Logger.SYSINIT, "started"); |
57 |
tdb |
1.1 |
} |
58 |
|
|
|
59 |
|
|
//---PUBLIC METHODS--- |
60 |
|
|
|
61 |
|
|
/** |
62 |
tdb |
1.5 |
* The write() method takes a line of text, pre-formatted |
63 |
|
|
* and outputs it using a method defined by the actual |
64 |
|
|
* implementation. The verbosity is given in case the |
65 |
|
|
* implementation wishes to utilise it in the layout - |
66 |
|
|
* eg. a different colour or font. |
67 |
|
|
* |
68 |
|
|
* This instance simply prints the message to the screen. |
69 |
|
|
* |
70 |
|
|
* @param line A line of formatted text to be logged |
71 |
|
|
* @param verbosity the verbosity of this message |
72 |
|
|
*/ |
73 |
tdb |
1.4 |
public synchronized void write(String line, int verbosity) {; |
74 |
|
|
System.out.println(line); |
75 |
tdb |
1.1 |
} |
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 |
tdb |
1.10 |
* This uses the uk.org.iscream.cms.util.FormatName class |
82 |
ajm |
1.3 |
* to format the toString() |
83 |
|
|
* |
84 |
tdb |
1.1 |
* @return the name of this class and its CVS revision |
85 |
|
|
*/ |
86 |
|
|
public String toString() { |
87 |
ajm |
1.3 |
return FormatName.getName( |
88 |
|
|
_name, |
89 |
|
|
getClass().getName(), |
90 |
|
|
REVISION); |
91 |
tdb |
1.1 |
} |
92 |
ajm |
1.3 |
|
93 |
tdb |
1.1 |
//---PRIVATE METHODS--- |
94 |
tdb |
1.5 |
|
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 |
tdb |
1.4 |
private void write(String source, int verbosity, String message) { |
104 |
|
|
write(FormatName.formatLogLine(source, verbosity, message), verbosity); |
105 |
tdb |
1.1 |
} |
106 |
|
|
|
107 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
108 |
|
|
|
109 |
|
|
//---ATTRIBUTES--- |
110 |
ajm |
1.3 |
|
111 |
|
|
/** |
112 |
|
|
* This is the friendly identifier of the |
113 |
|
|
* component this class is running in. |
114 |
|
|
* eg, a Filter may be called "filter1", |
115 |
|
|
* If this class does not have an owning |
116 |
|
|
* component, a name from the configuration |
117 |
|
|
* can be placed here. This name could also |
118 |
|
|
* be changed to null for utility classes. |
119 |
|
|
*/ |
120 |
|
|
private String _name = Core.NAME; |
121 |
tdb |
1.1 |
|
122 |
|
|
//---STATIC ATTRIBUTES--- |
123 |
|
|
|
124 |
tdb |
1.10 |
} |