com.ryanm.logging
Class FileSink

java.lang.Object
  extended by com.ryanm.logging.AbstractSink
      extended by com.ryanm.logging.StringSink
          extended by com.ryanm.logging.FileSink
All Implemented Interfaces:
Configurable, LogSink

public class FileSink
extends StringSink

Logs messages in human-readable format to the specified file. Each message is seperated by a line break

Author:
ryanm

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ryanm.logging.StringSink
StringSink.StringSinkConfigurator
 
Constructor Summary
FileSink(java.lang.String fileName, boolean append)
          Constructs a filesink
 
Method Summary
 Configurator getConfigurator()
          Gets a Configurator object that describes and can manipulate the variables of this Configurable.
 java.lang.String getFileName()
          Gets the name of the file that this sink writes to
 void setFileName(java.lang.String fileName, boolean append)
          Sets the name of the file that this sink will write to
protected  void writeString(java.lang.String s)
          This should be overridden to write the supplied string to wherever, stdOut, a file, something like that.
 
Methods inherited from class com.ryanm.logging.StringSink
log
 
Methods inherited from class com.ryanm.logging.AbstractSink
addSinkListener, getTitle, notifyListeners, removeSinkListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSink

public FileSink(java.lang.String fileName,
                boolean append)
Constructs a filesink

Parameters:
fileName - The name of the file to write to
append - True to make the sink write messages to the end of an existing file, false to overwrite
Method Detail

writeString

protected void writeString(java.lang.String s)
Description copied from class: StringSink
This should be overridden to write the supplied string to wherever, stdOut, a file, something like that.

Specified by:
writeString in class StringSink
Parameters:
s - The String to write

getFileName

public java.lang.String getFileName()
Gets the name of the file that this sink writes to

Returns:
The name of the file

setFileName

public void setFileName(java.lang.String fileName,
                        boolean append)
Sets the name of the file that this sink will write to

Parameters:
fileName - The filename
append - true to make the sink append to the end of an existing file, false to overwrite

getConfigurator

public Configurator getConfigurator()
Description copied from interface: Configurable
Gets a Configurator object that describes and can manipulate the variables of this Configurable. This method must only return null if the Configurable object is Annotated such that an AnnotatedConfigurator can be built from it.

Specified by:
getConfigurator in interface Configurable
Overrides:
getConfigurator in class StringSink
Returns:
A configurator object, or null if annotated