1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.core.loggers; |
2 |
> |
package uk.org.iscream.cms.server.core.loggers; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.util.*; |
6 |
< |
import uk.ac.ukc.iscream.core.*; |
5 |
> |
import uk.org.iscream.cms.server.util.*; |
6 |
> |
import uk.org.iscream.cms.server.core.*; |
7 |
|
import java.util.Date; |
8 |
|
import java.text.DateFormat; |
9 |
|
import java.util.Locale; |
46 |
|
* @throws IOException if there is a problem with the file check. |
47 |
|
*/ |
48 |
|
public FileLogger() throws IOException{ |
49 |
< |
filename = System.getProperty("uk.ac.ukc.iscream.LoggerClass.FileLogger.filename"); |
49 |
> |
filename = System.getProperty("uk.org.iscream.cms.server.LoggerClass.FileLogger.filename"); |
50 |
|
// Perform file check to make sure writing is ok |
51 |
|
if(!fileCheck()){ |
52 |
|
// Have to system.out.println errors because logging mechanism failed ! |
68 |
|
|
69 |
|
//---PUBLIC METHODS--- |
70 |
|
|
71 |
< |
/** |
72 |
< |
* The write() method writes a line of log to the file, prepending |
73 |
< |
* it with some information about where to line came from and the |
74 |
< |
* date. This formatting is handled by the formatLogLine() method. |
75 |
< |
* There is some synchronisation here due to problems with the logfiles |
76 |
< |
* having multiple lines written on the same line, followed by dotted |
77 |
< |
* newlines in the wrong places. This is due to this method being |
78 |
< |
* called by multiple threads. |
71 |
> |
/** |
72 |
> |
* The write() method takes a line of text, pre-formatted |
73 |
> |
* and outputs it using a method defined by the actual |
74 |
> |
* implementation. The verbosity is given in case the |
75 |
> |
* implementation wishes to utilise it in the layout - |
76 |
> |
* eg. a different colour or font. |
77 |
|
* |
78 |
< |
* @param source A string representation of the calling object. |
79 |
< |
* @param message The message to be logged. |
80 |
< |
*/ |
78 |
> |
* This instance writes the line to a file. |
79 |
> |
* |
80 |
> |
* @param line A line of formatted text to be logged |
81 |
> |
* @param verbosity the verbosity of this message |
82 |
> |
*/ |
83 |
|
public synchronized void write(String line, int verbosity) { |
84 |
|
// Check to make sure file is open |
85 |
|
if(open){ |
241 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
242 |
|
* method to provide clean logging (every class should have this). |
243 |
|
* |
244 |
< |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
244 |
> |
* This uses the uk.org.iscream.cms.server.util.FormatName class |
245 |
|
* to format the toString() |
246 |
|
* |
247 |
|
* @return the name of this class and its CVS revision |
290 |
|
return fileOK; |
291 |
|
} |
292 |
|
|
293 |
+ |
/** |
294 |
+ |
* This method is provided if this class wishes to log |
295 |
+ |
* a message itself. |
296 |
+ |
* |
297 |
+ |
* @param source A String representation of the source |
298 |
+ |
* @param verbosity the verbosity of this message |
299 |
+ |
* @param message The message to log |
300 |
+ |
*/ |
301 |
|
private void write(String source, int verbosity, String message) { |
302 |
|
write(FormatName.formatLogLine(source, verbosity, message), verbosity); |
303 |
|
} |