org.schmant.report
Class FileReport

java.lang.Object
  extended by org.schmant.report.AbstractReport
      extended by org.schmant.report.AbstractPrintingReport
          extended by org.schmant.report.FileReport
All Implemented Interfaces:
Report

public class FileReport
extends AbstractPrintingReport

This Report prints its output to a file.

Since:
0.6
Author:
Karl Gustafsson

Constructor Summary
FileReport(String identifier, ReportLineFormatter llf, WritableFile f, boolean append)
          Create a new FileReport.
FileReport(String identifier, WritableFile f)
          Create a new FileReport.
 
Method Summary
 void close()
          Close the current report.
protected  void printLine(Level l, String line)
          Print the formatted line.
protected  void printStacktrace(Level l, String s)
          Print a stacktrace.
 
Methods inherited from class org.schmant.report.AbstractPrintingReport
debug, error, error, getIdentifier, getReportLineFormatter, getSeverityText, getStackTraceWriter, info, log, log, trace, warn, warn
 
Methods inherited from class org.schmant.report.AbstractReport
getLevel, isDebugReported, isErrorReported, isInfoReported, isLevelReported, isOpen, isTraceReported, isWarnReported, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReport

public FileReport(String identifier,
                  ReportLineFormatter llf,
                  WritableFile f,
                  boolean append)
Create a new FileReport. This opens the file for writing/appending. The file will be kept open until close() is called.

Parameters:
identifier - This report's identifier. Can be null.
llf - The ReportLineFormatter to use for formatting log lines in the report.
f - The file to write to. This file is opened by this method and closed when close() is called.
append - Should the log file be opened for appending (true), preserving old data in the file, or should old data be overwritten false.

FileReport

public FileReport(String identifier,
                  WritableFile f)
Create a new FileReport. This opens the file for writing (discarding old data in the file). The file will be kept open until close() is called.

Log lines in the report will be formatted using the SimpleReportLineFormatter.

Parameters:
identifier - This report's identifier. Can be null.
f - The file to write to. This file is opened by this method and closed when close() is called.
Method Detail

printLine

protected void printLine(Level l,
                         String line)
Description copied from class: AbstractPrintingReport
Print the formatted line.

Specified by:
printLine in class AbstractPrintingReport
Parameters:
l - The severity of the log message. It is already verified that log messages of this severity should be printed.
line - The formatted log line.

printStacktrace

protected void printStacktrace(Level l,
                               String s)
Description copied from class: AbstractPrintingReport
Print a stacktrace.

Specified by:
printStacktrace in class AbstractPrintingReport
Parameters:
l - The severity of the log message. It is already verified that log messages of this severity should be printed.
s - The formatted stack trace, including newlines.

close

public void close()
Description copied from interface: Report
Close the current report. After calling this method the report does not accept any new messages. This is called when Schmant exits or when a new report is started.

Specified by:
close in interface Report
Overrides:
close in class AbstractReport