Class FileTracer

java.lang.Object
overit.geocall.util.tracer.FileTracer
All Implemented Interfaces:
Tracer

public class FileTracer extends Object implements Tracer
This class implements the interface class Tracer and creates an instance of the tracer. This tracer print in the file the records of the log.
The path of the file or the file passed as the first parameter of the constructor (see FileTracer(path,charset) and FileTracer(file,charset)).
  • Field Details

    • _pw

      protected PrintWriter _pw
    • _line

      protected int _line
    • _time

      protected long _time
    • _sdf

      protected final SimpleDateFormat _sdf
  • Constructor Details

    • FileTracer

      public FileTracer(String file, String charset)
      Class constructor using the first parameter to determine the path of the file in which to print the log lines.
      Parameters:
      file - Path of the file
      charset - String rappresents the charset of the file.
    • FileTracer

      public FileTracer(File file, String charset)
      Class constructor using the first parameter as file in which to print the log lines.
      Parameters:
      file - Path of the file
      charset - String rappresents the charset of the file.
  • Method Details

    • record

      public void record(String name, Object val)
      Adds a record of log to the file.
      Specified by:
      record in interface Tracer
      Parameters:
      name - String contains the name of the record to put in the registry.
      val - The value to put in the registry.
    • stop

      public void stop()
      Method to call when the execution is finished. Takes care of calculating the execution time as a delta between the start and end processing time and to close the writing channel.
      Specified by:
      stop in interface Tracer
    • finalize

      public void finalize()
      Override of the method Object.finalize() that recalls stop(). It is used to close the writing channel when the object is garbaged.
      Overrides:
      finalize in class Object
    • getTraceTime

      public long getTraceTime()
      Return the time of the execution. If the stop() or Object.finalize() have not been called, the value returned will be 0.
      Specified by:
      getTraceTime in interface Tracer
      Returns:
      The time of the execution.