Service Activator Toolkit
Version 1.0.0

org.eclipse.soda.sat.core.framework.interfaces
Interface IFileLog


public interface IFileLog

The IFileLog interface defines the API for a file-based log. An instance of IFileLog can be created using the FactoryUtility singleton.

 File file = ...
 FactoryUtility utility = FactoryUtility.getInstance();
 IFileLog fileLog = utility.createFileLog(file);
 
An IFileLog must be opened before it can be written to, and closed after use. For example:
 try {
   fileLog.open();
   fileLog.log(this, "Hello World");
 } catch (IOException exception) {
   ...
 } finally {
   fileLog.close();
 }
 
For convenience, the LogUtility singleton has a built-in IFileLog that may be written to using its logToFile(Object, String) and traceToFile(Object, String) methods.

See Also:
FactoryUtility, LogUtility

Method Summary
 void close()
          Close the file.
 boolean delete()
          Delete the file.
 String getFilename()
          Get the name of the file.
 void log(Object id, String message)
          Write the specified message to the file.
 void open()
          Open the file.
 

Method Detail

close

public void close()
           throws IOException
Close the file.

Throws:
IOException

delete

public boolean delete()
               throws IOException
Delete the file.

Returns:
True if the file was deleted, otherwise false.
Throws:
IOException

getFilename

public String getFilename()
Get the name of the file.

Returns:
String

log

public void log(Object id,
                String message)
         throws IOException
Write the specified message to the file. This method is provided for debugging purposes only. Since this method makes use of local file I/O, this should typically not be called in production code.

Parameters:
id - An object that identifies who is logging the message.
message - The message to log.
Throws:
IOException

open

public void open()
          throws FileNotFoundException
Open the file.

Throws:
FileNotFoundException

Service Activator Toolkit
Version 1.0.0