Class CSVLogger

java.lang.Object
log.CSVLogger

public class CSVLogger extends Object

Name: CSVLogger

Description: A logger implementation that writes its output on a given CSV file. This class is thread-safe, so multiple threads may concurrently write on the same output file sharing the same CSVLogger instance.

Date: 11/dic/2009 Time: 17.16.14

Version:
1.0
Author:
Bertoli Marco
  • Constructor Details

    • CSVLogger

      public CSVLogger(File file, String[] columns, boolean append, String colSep, String digitSep)
      Creates a new CSVLogger that writes to the given file
      Parameters:
      file - the file we should write to
      columns - the columns for the log file
      append - true to append to an existing file. False to create a new file
      colSep - the column separator
      digitSep - the decimal digit separator
  • Method Details

    • log

      public void log(Map<String,?> values, Map<String,?> defaultValues) throws IOException
      Logs the given values. Only the actual writing to the stream is synchronized. This method is designed so that each log line will never be mixed with another one.
      Parameters:
      values - a map with the value for each column
      defaultValues - a map with default values for the log. Whenever a value is not found in values map, it is looked in defaultValues map.
      Throws:
      IOException - if a problem is risen opening or writing to the log file
    • dispose

      protected void dispose() throws IOException
      Disposes this logger object, closing the writer.
      Throws:
      IOException - if an IO problem is risen closing the log file.
    • getFile

      public File getFile()
      Returns the file.
      Returns:
      the file this logger is writing on.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable