Package fmpp.progresslisteners
Class LoggerProgressListener
- java.lang.Object
-
- fmpp.progresslisteners.LoggerProgressListener
-
- All Implemented Interfaces:
ProgressListener
public class LoggerProgressListener extends java.lang.Object implements ProgressListener
Writes detailed information about errors and warning messages into a file or into any character stream.
-
-
Field Summary
-
Fields inherited from interface fmpp.ProgressListener
EVENT_BEGIN_FILE_PROCESSING, EVENT_BEGIN_PROCESSING_SESSION, EVENT_CREATED_EMPTY_DIR, EVENT_END_FILE_PROCESSING, EVENT_END_PROCESSING_SESSION, EVENT_IGNORING_DIR, EVENT_SOURCE_NOT_MODIFIED, EVENT_WARNING
-
-
Constructor Summary
Constructors Constructor Description LoggerProgressListener()
Output will be printed to the stderr.LoggerProgressListener(java.io.File logFile)
LoggerProgressListener(java.io.File logFile, boolean append)
LoggerProgressListener(java.io.OutputStream out)
LoggerProgressListener(java.io.PrintWriter out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the PrintWriter used for printing into the log.void
flush()
Flushes the PrintWriter used for printing into the log.java.io.PrintWriter
getPrintWriter()
Returns the PrintWriter used for printing into the log.void
notifyProgressEvent(Engine engine, int event, java.io.File src, int pMode, java.lang.Throwable error, java.lang.Object param)
Method called be the engine to notify events.void
println()
Prints line-break into the log.void
println(java.lang.Object obj)
Prints into the log with word-wrapping.void
println(java.lang.String text)
Prints into the log with word-wrapping.void
println(java.lang.String text, int indent)
Prints into the log with word-wrapping and indentation.void
printlnNW(java.lang.String text)
Prints into the log without word-wrapping.void
printNW(java.lang.String text)
Prints into the log without word-wrapping.void
printStackTrace(java.lang.Throwable exc)
-
-
-
Constructor Detail
-
LoggerProgressListener
public LoggerProgressListener()
Output will be printed to the stderr.
-
LoggerProgressListener
public LoggerProgressListener(java.io.OutputStream out)
-
LoggerProgressListener
public LoggerProgressListener(java.io.PrintWriter out)
-
LoggerProgressListener
public LoggerProgressListener(java.io.File logFile) throws java.io.IOException
- Throws:
java.io.IOException
-
LoggerProgressListener
public LoggerProgressListener(java.io.File logFile, boolean append) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
notifyProgressEvent
public void notifyProgressEvent(Engine engine, int event, java.io.File src, int pMode, java.lang.Throwable error, java.lang.Object param)
Description copied from interface:ProgressListener
Method called be the engine to notify events.It is guaranteed that this method will not be called concurrently as far as the listener is added to a single
Engine
instance only.- Specified by:
notifyProgressEvent
in interfaceProgressListener
- Parameters:
engine
- The engine instance where the event has occurred.event
- The code of the event: anEVENT_...
constant. As new event types can be introduced with new FMPP versions (even if it happens very seldom), a progress listener implementation should survive events that it does not understand. That is, it must not stop with an error, but it should silently ignore the event.src
- Depending onevent
the source file or null.pMode
- Depending onevent
the proccessing mode (Engine.PMODE_...
constant) orEngine.PMODE_NONE
. Note that new processing modes may be added as FMPP evolvers, so values that are not known be the progress listener should be handler nicely, and never cause error.error
- The error, or null if there was no error.param
- Extra information about the event. The class and meaning of object depends on the concrete event:- For
EVENT_WARNING
it is aString
that describles the reason of warning.
- For
-
getPrintWriter
public java.io.PrintWriter getPrintWriter()
Returns the PrintWriter used for printing into the log.
-
close
public void close()
Closes the PrintWriter used for printing into the log.
-
flush
public void flush()
Flushes the PrintWriter used for printing into the log.
-
printlnNW
public void printlnNW(java.lang.String text)
Prints into the log without word-wrapping.
-
printNW
public void printNW(java.lang.String text)
Prints into the log without word-wrapping.
-
println
public void println()
Prints line-break into the log.
-
println
public void println(java.lang.Object obj)
Prints into the log with word-wrapping.
-
println
public void println(java.lang.String text)
Prints into the log with word-wrapping.
-
println
public void println(java.lang.String text, int indent)
Prints into the log with word-wrapping and indentation.
-
printStackTrace
public void printStackTrace(java.lang.Throwable exc)
-
-