Class FileLogger
java.lang.Object
org.apache.maven.shared.scriptinterpreter.FileLogger
- All Implemented Interfaces:
ExecutionLogger
- Version:
- $Id: FileLogger.java 1389141 2012-09-23 20:29:01Z hboutemy $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File
The path to the log file.private final org.apache.maven.plugin.logging.Log
The optional mojo logger to additionally write messages to, can benull
.private boolean
A flag whether the output stream should be closed during finalization of this logger.private PrintStream
The underlying file stream this logger writes to. -
Constructor Summary
ConstructorsConstructorDescriptionFileLogger
(File outputFile) Creates a new logger that writes to the specified file.FileLogger
(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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the underlying file stream.void
consumeLine
(String line) Writes the specified line to the log file and optionally to the mojo logger.protected void
finalize()
Closes the underlying file stream.Gets the path to the output file.Gets the underlying stream used to write message to the log file.
-
Field Details
-
file
The path to the log file. -
stream
The underlying file stream this logger writes to. -
shouldFinalize
private boolean shouldFinalizeA flag whether the output stream should be closed during finalization of this logger. -
log
private final org.apache.maven.plugin.logging.Log logThe optional mojo logger to additionally write messages to, can benull
.
-
-
Constructor Details
-
FileLogger
Creates a new logger that writes to the specified file.- Parameters:
outputFile
- The path to the output file, must not benull
.- Throws:
IOException
- If the output file could not be created.
-
FileLogger
Creates a new logger that writes to the specified file and optionally mirrors messages to the given mojo logger.- Parameters:
outputFile
- The path to the output file, must not benull
.log
- The mojo logger to additionally output messages to, may benull
if not used.- Throws:
IOException
- If the output file could not be created.
-
-
Method Details
-
getOutputFile
Gets the path to the output file.- Returns:
- The path to the output file, never
null
.
-
getPrintStream
Gets the underlying stream used to write message to the log file.- Specified by:
getPrintStream
in interfaceExecutionLogger
- Returns:
- The underlying stream used to write message to the log file, never
null
.
-
consumeLine
Writes the specified line to the log file and optionally to the mojo logger.- Specified by:
consumeLine
in interfaceExecutionLogger
- Parameters:
line
- The message to log.
-
close
public void close()Closes the underlying file stream. -
finalize
protected void finalize()Closes the underlying file stream.
-