Class FileLogger

java.lang.Object
org.apache.maven.shared.scriptinterpreter.FileLogger
All Implemented Interfaces:
AutoCloseable, ExecutionLogger

public class FileLogger extends Object implements ExecutionLogger, AutoCloseable

FileLogger class.

  • Constructor Details

    • FileLogger

      public FileLogger(File outputFile) throws IOException
      Creates a new logger that writes to the specified file.
      Parameters:
      outputFile - The path to the output file, if null all message will be discarded.
      Throws:
      IOException - If the output file could not be created.
    • FileLogger

      public FileLogger(File outputFile, FileLoggerMirrorHandler mirrorHandler) throws IOException
      Creates a new logger that writes to the specified file and optionally mirrors messages.
      Parameters:
      outputFile - The path to the output file, if null all message will be discarded.
      mirrorHandler - The class which handle mirrored message, can be null.
      Throws:
      IOException - If the output file could not be created.
  • Method Details

    • getOutputFile

      public File getOutputFile()
      Gets the path to the output file.
      Returns:
      The path to the output file, never null.
    • getPrintStream

      public PrintStream getPrintStream()
      Gets the underlying stream used to write message to the log file.
      Specified by:
      getPrintStream in interface ExecutionLogger
      Returns:
      The underlying stream used to write message to the log file, never null.
    • consumeLine

      public void consumeLine(String line)
      Writes the specified line to the log file and invoke FileLoggerMirrorHandler.consumeOutput(String) if is given.
      Specified by:
      consumeLine in interface ExecutionLogger
      Parameters:
      line - The message to log.
    • close

      public void close()
      Closes the underlying file stream.
      Specified by:
      close in interface AutoCloseable