|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.org.iscream.cms.server.core.loggers.FileLogger
public class FileLogger
The FileLogger is an implementation of the LoggerImpl defined in the associated interface. It provides quite extensive features to allow logging ot a text file.
Field Summary | |
---|---|
private String |
_name
This is the friendly identifier of the component this class is running in. |
private String |
filename
The filename of the currently open, or last open, file. |
private boolean |
open
A boolean signifying whether a file is open or not. |
String |
REVISION
The current CVS revision of this class |
private BufferedWriter |
writer
A reference to the writer being used. |
Constructor Summary | |
---|---|
FileLogger()
Creates a new FileLogger. |
Method Summary | |
---|---|
void |
clear()
The clear() method erases the contents of the logfile. |
void |
close()
The close() method closes the logfile and no more data can be written. |
private boolean |
fileCheck()
The fileCheck() method is used to ensure that writing is ok. |
void |
open(String filename)
The open() method opens a new file after the close() method has been called on the FileLog. |
void |
resume()
The resume() method resumes writing to the file by setting the open boolean to true. |
void |
suspend()
The suspend() method halts writing to the file by setting the open boolean to false, and thus blocking the write() method. |
String |
toString()
Overrides the Object.toString()
method to provide clean logging (every class should have this). |
void |
write(String line,
int verbosity)
The write() method takes a line of text, pre-formatted and outputs it using a method defined by the actual implementation. |
private void |
write(String source,
int verbosity,
String message)
This method is provided if this class wishes to log a message itself. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final String REVISION
private String filename
private BufferedWriter writer
private boolean open
private String _name
Constructor Detail |
---|
public FileLogger() throws IOException
IOException
- if there is a problem with the file check.Method Detail |
---|
public void write(String line, int verbosity)
write
in interface LoggerImpl
line
- A line of formatted text to be loggedverbosity
- the verbosity of this messagepublic void clear()
public void close()
public void open(String filename) throws IOException
filename
- The new file to write to.
IOException
- if the file cannot be written to.public void suspend()
public void resume()
public String toString()
Object.toString()
method to provide clean logging (every class should have this).
This uses the uk.org.iscream.cms.util.FormatName class
to format the toString()
toString
in class Object
private boolean fileCheck()
private void write(String source, int verbosity, String message)
source
- A String representation of the sourceverbosity
- the verbosity of this messagemessage
- The message to log
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |