Package overit.geocall.util.tracer
Class FileTracer
java.lang.Object
overit.geocall.util.tracer.FileTracer
- All Implemented Interfaces:
Tracer
This class implements the interface class
The path of the file or the file passed as the first parameter of the constructor (see
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 Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected PrintWriterprotected final SimpleDateFormatprotected long -
Constructor Summary
ConstructorsConstructorDescriptionFileTracer(File file, String charset) Class constructor using the first parameter as file in which to print the log lines.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. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Override of the methodObject.finalize()that recallsstop().longReturn the time of the execution.voidAdds a record of log to the file.voidstop()Method to call when the execution is finished.
-
Field Details
-
_pw
-
_line
protected int _line -
_time
protected long _time -
_sdf
-
-
Constructor Details
-
FileTracer
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 filecharset- String rappresents the charset of the file.
-
FileTracer
Class constructor using the first parameter as file in which to print the log lines.- Parameters:
file- Path of the filecharset- String rappresents the charset of the file.
-
-
Method Details
-
record
Adds a record of log to the file. -
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. -
finalize
public void finalize()Override of the methodObject.finalize()that recallsstop(). It is used to close the writing channel when the object is garbaged. -
getTraceTime
public long getTraceTime()Return the time of the execution. If thestop()orObject.finalize()have not been called, the value returned will be 0.- Specified by:
getTraceTimein interfaceTracer- Returns:
- The time of the execution.
-