public class FileLogger extends java.lang.Object implements ExecutionLogger
Modifier and Type | Field and Description |
---|---|
private java.io.File |
file
The path to the log file.
|
private org.apache.maven.plugin.logging.Log |
log
The optional mojo logger to additionally write messages to, can be
nulll . |
private boolean |
shouldFinalize
A flag whether the output stream should be closed during finalization of this logger.
|
private java.io.PrintStream |
stream
The underlying file stream this logger writes to.
|
Constructor and Description |
---|
FileLogger(java.io.File outputFile)
Creates a new logger that writes to the specified file.
|
FileLogger(java.io.File outputFile,
org.apache.maven.plugin.logging.Log log)
Creates a new logger that writes to the specified file and optionally mirrors messages to the given mojo logger.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying file stream.
|
void |
consumeLine(java.lang.String line)
Writes the specified line to the log file and optionally to the mojo logger.
|
protected void |
finalize()
Closes the underlying file stream.
|
java.io.File |
getOutputFile()
Gets the path to the output file.
|
java.io.PrintStream |
getPrintStream()
Gets the underlying stream used to write message to the log file.
|
private java.io.File file
private java.io.PrintStream stream
private boolean shouldFinalize
private final org.apache.maven.plugin.logging.Log log
nulll
.public FileLogger(java.io.File outputFile) throws java.io.IOException
outputFile
- The path to the output file, must not be null
.java.io.IOException
- If the output file could not be created.public FileLogger(java.io.File outputFile, org.apache.maven.plugin.logging.Log log) throws java.io.IOException
outputFile
- The path to the output file, must not be null
.log
- The mojo logger to additionally output messages to, may be null
if not used.java.io.IOException
- If the output file could not be created.public java.io.File getOutputFile()
null
.public java.io.PrintStream getPrintStream()
getPrintStream
in interface ExecutionLogger
null
.public void consumeLine(java.lang.String line)
consumeLine
in interface ExecutionLogger
line
- The message to log.public void close()
protected void finalize()
finalize
in class java.lang.Object