1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* http://www.i-scream.org.uk |
4 |
+ |
* 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 |
|
//---PACKAGE DECLARATION--- |
22 |
< |
package uk.ac.ukc.iscream.core.loggers; |
22 |
> |
package uk.org.iscream.cms.server.core.loggers; |
23 |
|
|
24 |
|
//---IMPORTS--- |
25 |
< |
import uk.ac.ukc.iscream.util.*; |
26 |
< |
import uk.ac.ukc.iscream.core.*; |
25 |
> |
import uk.org.iscream.cms.util.*; |
26 |
> |
import uk.org.iscream.cms.server.core.*; |
27 |
|
import java.io.IOException; |
28 |
|
|
29 |
|
/** |
58 |
|
//---PUBLIC METHODS--- |
59 |
|
|
60 |
|
/** |
61 |
< |
* The write() method takes a message, formats it using the |
62 |
< |
* formatLogLine() method, and then outputs it to the screen |
63 |
< |
* using System.out.println(). The source is usually the |
64 |
< |
* calling object, referenced by `this'. The method has been |
65 |
< |
* made synchronized to avoid it being called by two different |
66 |
< |
* objects and the output ending up merged on the screen. |
67 |
< |
* |
68 |
< |
* @param source A string representation of the calling object. |
69 |
< |
* @param verbosity the verbosity of this message |
70 |
< |
* @param message The text to be logged. |
71 |
< |
*/ |
72 |
< |
public synchronized void write(String source, int verbosity, String message) { |
73 |
< |
_screenlog.write(source, verbosity, message); |
74 |
< |
_filelog.write(source, verbosity, message); |
61 |
> |
* The write() method takes a line of text, pre-formatted |
62 |
> |
* and outputs it using a method defined by the actual |
63 |
> |
* implementation. The verbosity is given in case the |
64 |
> |
* implementation wishes to utilise it in the layout - |
65 |
> |
* eg. a different colour or font. |
66 |
> |
* |
67 |
> |
* This instance passes the message on to a ScreenLogger |
68 |
> |
* and a FileLogger. |
69 |
> |
* |
70 |
> |
* @param line A line of formatted text to be logged |
71 |
> |
* @param verbosity the verbosity of this message |
72 |
> |
*/ |
73 |
> |
public synchronized void write(String line, int verbosity) { |
74 |
> |
_screenlog.write(line, verbosity); |
75 |
> |
_filelog.write(line, verbosity); |
76 |
|
} |
77 |
|
|
78 |
|
/** |
79 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
80 |
|
* method to provide clean logging (every class should have this). |
81 |
|
* |
82 |
< |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
82 |
> |
* This uses the uk.org.iscream.cms.util.FormatName class |
83 |
|
* to format the toString() |
84 |
|
* |
85 |
|
* @return the name of this class and its CVS revision |
92 |
|
} |
93 |
|
|
94 |
|
//---PRIVATE METHODS--- |
95 |
+ |
|
96 |
+ |
/** |
97 |
+ |
* This method is provided if this class wishes to log |
98 |
+ |
* a message itself. |
99 |
+ |
* |
100 |
+ |
* @param source A String representation of the source |
101 |
+ |
* @param verbosity the verbosity of this message |
102 |
+ |
* @param message The message to log |
103 |
+ |
*/ |
104 |
+ |
private void write(String source, int verbosity, String message) { |
105 |
+ |
write(FormatName.formatLogLine(source, verbosity, message), verbosity); |
106 |
+ |
} |
107 |
|
|
108 |
|
//---ACCESSOR/MUTATOR METHODS--- |
109 |
|
|
132 |
|
|
133 |
|
//---STATIC ATTRIBUTES--- |
134 |
|
|
135 |
< |
} |
135 |
> |
} |