com.Prominic.jFTPd
Class FTPLogger

java.lang.Object
  extended by com.Prominic.jFTPd.FTPLogger
All Implemented Interfaces:
java.util.Observer

public class FTPLogger
extends java.lang.Object
implements java.util.Observer

This class receives FTPEvents and logs them into the log file.

Author:
Iulian

Field Summary
protected  java.text.DateFormat dateFormat
           
protected  boolean echoEnabled
           
protected  boolean errorEchoEnabled
           
protected  java.io.PrintWriter errout
           
protected  java.lang.String lineEnding
           
protected  java.io.PrintWriter logout
           
 
Constructor Summary
FTPLogger(java.lang.String logfile, java.lang.String errfile)
          Creates an FTPLogger class.
 
Method Summary
protected static java.lang.String exceptionStackTrace(java.lang.Throwable t)
          Returns the exception's stack trace, as String.
 void log(java.util.Date date, java.lang.String entry, java.io.PrintWriter out)
          Logs a message to the log file.
 void logFTPEvent(FTPEvent event)
          Logs an FTPEvent (including arguments of the event).
 void setEchoEnabled(boolean q)
          Sets if log messages should be displayed on STDOUT.
 void setErrorEchoEnabled(boolean q)
          Sets if error messages should be displayed on STDOUT.
 void update(java.util.Observable o, java.lang.Object arg)
          Called when there's and FTPEvent which needs to be logged.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

echoEnabled

protected boolean echoEnabled

errorEchoEnabled

protected boolean errorEchoEnabled

logout

protected java.io.PrintWriter logout

errout

protected java.io.PrintWriter errout

dateFormat

protected java.text.DateFormat dateFormat

lineEnding

protected java.lang.String lineEnding
Constructor Detail

FTPLogger

public FTPLogger(java.lang.String logfile,
                 java.lang.String errfile)
          throws java.io.IOException
Creates an FTPLogger class.

Parameters:
logfile - - log file
errfile - - error file
Throws:
java.io.IOException - - if something goes wrong while opening the files.
Method Detail

exceptionStackTrace

protected static java.lang.String exceptionStackTrace(java.lang.Throwable t)
Returns the exception's stack trace, as String.

Parameters:
t - - exception
Returns:
- string representation of the stack trace.

log

public void log(java.util.Date date,
                java.lang.String entry,
                java.io.PrintWriter out)
Logs a message to the log file. If the "out" parameter is the log file or the error file, the the message is also displayed on the console, based on how jFTPd was configured.

Parameters:
date - - date of log
entry - - message
out - - log output stream.

logFTPEvent

public void logFTPEvent(FTPEvent event)
Logs an FTPEvent (including arguments of the event).

Parameters:
event - - event to be logged.

setEchoEnabled

public void setEchoEnabled(boolean q)
Sets if log messages should be displayed on STDOUT.

Parameters:
q - - echo enabled or not.

setErrorEchoEnabled

public void setErrorEchoEnabled(boolean q)
Sets if error messages should be displayed on STDOUT.

Parameters:
q - - error echo enabled.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Called when there's and FTPEvent which needs to be logged.

Specified by:
update in interface java.util.Observer
Parameters:
o - - observable (not used).
arg - - must be FTPEvent.