Class LogFileHandler

java.lang.Object
outputProviders.LogFileHandler

public class LogFileHandler extends Object
Handles the writing of log files for the application. Provides methods for writing iteration results, summaries, log overviews, log histories, error histories, and closing the log file.
  • Constructor Details

    • LogFileHandler

      public LogFileHandler()
  • Method Details

    • generateActualLogs

      public void generateActualLogs(List<IterationResult> results, Map<Integer,List<IterationResult>> iterationResultsByErrorCode, Map<String,List<IterationResult>> iterationResultsByOutputMessage, long elaspedTime)
      Generates all logs in the actual_logs subdirectory, that are only about this stimulation. This subdirectory contains three files:
      • log.txt - A text file that contains all the iteration results.
      • log.csv - A CSV file that contains all the iteration results.
      • log_overview.csv - A CSV file that contains all possible combinations of unique error codes and output messages, and the number of times, as well as which iteration numbers, they occur.
      Parameters:
      results - All the results that we need to write the log file about.
      iterationResultsByErrorCode - Map that has a list of iterations results for each error code, sorted by occurrence.
      iterationResultsByOutputMessage - Map that has a list of iterations results for each output message, sorted by occurrence.
      elaspedTime - Elapsed time of the simulation.
    • generateOverviewLogs

      public void generateOverviewLogs(List<IterationResult> iterationResults, Map<Integer,List<IterationResult>> iterationResultsByErrorCode, Map<String,List<IterationResult>> iterationResultsByOutputMessage, long elapsedTime)
      Generates all logs in the log_history subdirectory. These files possibly already contain results from other stimulation's that are run previously. This subdirectory contains multiple files:
      • log_fullHistory.csv - A CSV file that contains all the iteration results of all the previous stimulation's.
      • log_history.csv - A CSV file that contains general information about each stimulation (such as exit code counts, timestamps, ...).
      • log_errorHistory.csv - A CSV file that contains all the error codes and the number of times they occur in that stimulation, for each stimulation.
      • log_fullHistory_html directory: A directory that contains multiple HTML pages reporting about the iteration results of all the stimulation's. The implementation of generating these pages is deferred to the LogHTMLFileHandler class.
      Parameters:
      iterationResults - All the results that we want to append to the historical log files.
      iterationResultsByErrorCode - Map that has a list of iterations results for each error code, sorted by occurrence.
      iterationResultsByOutputMessage - Map that has a list of iterations results for each output message, sorted by occurrence.
      elapsedTime - Elapsed time of the simulation.
    • openWriterCheck

      public void openWriterCheck(String filePath)
      If possible, opens the log file for writing.
      Parameters:
      filePath - The path of the log file.
    • generateLogCSVFile

      public void generateLogCSVFile()
      Writes the log CSV file. For each iteration of this run, one row.

      Same information as log text file.

    • generateLogOverview

      public void generateLogOverview()
      Generates a log overview in CSV format based on the iteration results. Each unique combination of error codes and message outputs is one row in the csv. The iteration numbers where this combination occurred are given, and counted. Writes the log overview to a CSV file specified in the FileHandler.
    • generateLogHistory

      public void generateLogHistory()
      Generates a log history in CSV format based on the iteration results. Appends the log history to a CSV file specified in the FileHandler.

      If file did not yet exist, create one and write header. Otherwise, append row.

      Each run gets one row with the following information: FuzzAttemptNr - Time and date - Elapsed time - Counts of each of the iterations with the errorcodes.

    • generateLogErrorHistory

      public void generateLogErrorHistory()
      Generates a log error history in CSV format based on the iteration results. Appends the log error history to a CSV file specified in the FileHandler.

      If file did not yet exist, create one and write header. Otherwise, append rows.

      Each unique combination of run (and timestamp) - errorcode - output message is one row. Counts instances.

    • generateFullLogHistory

      public void generateFullLogHistory()
      Generates a full log history CSV file based on the provided iteration results. If the log history file is empty, it appends the header to the file. For subsequent runs, it modifies the "Map File Path" column for previous attempts.
    • generateFullLogHistoryHTMLReport

      public void generateFullLogHistoryHTMLReport()
      Generates a full log history HTML report based on the provided iteration results.