Package lcm.logging
Class Log
- java.lang.Object
-
- lcm.logging.Log
-
public class Log extends java.lang.ObjectA class for reading and writing LCM log files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLog.EventRepresents a single received LCM message.
-
Constructor Summary
Constructors Constructor Description Log(java.lang.String path, java.lang.String mode)Opens a log file for reading or writing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the log file and releases and system resources used by it.voidflush()Flush any unwritten data to the underlying file descriptor.java.lang.StringgetPath()Retrieves the path to the log file.doublegetPositionFraction()Log.EventreadNext()Reads the next event in the log filevoidseekPositionFraction(double frac)Seek to a position in the log file, specified by a fraction.voidwrite(long utime, java.lang.String channel, LCMEncodable msg)A convenience method for write.voidwrite(Log.Event e)Writes an event to the log file.
-
-
-
Constructor Detail
-
Log
public Log(java.lang.String path, java.lang.String mode) throws java.io.IOExceptionOpens a log file for reading or writing.- Parameters:
path- the filename to openmode- Specifies the access mode, must be one of "r", "rw", "rws", or "rwd". SeeRandomAccessFilefor more detail.- Throws:
java.io.IOException
-
-
Method Detail
-
getPath
public java.lang.String getPath()
Retrieves the path to the log file.- Returns:
- the path to the log file
-
flush
public void flush() throws java.io.IOExceptionFlush any unwritten data to the underlying file descriptor.- Throws:
java.io.IOException
-
readNext
public Log.Event readNext() throws java.io.IOException
Reads the next event in the log file- Throws:
java.io.EOFException- if the end of the file has been reached.java.io.IOException
-
getPositionFraction
public double getPositionFraction() throws java.io.IOException- Throws:
java.io.IOException
-
seekPositionFraction
public void seekPositionFraction(double frac) throws java.io.IOExceptionSeek to a position in the log file, specified by a fraction.- Parameters:
frac- a number in the range [0, 1)- Throws:
java.io.IOException
-
write
public void write(Log.Event e) throws java.io.IOException
Writes an event to the log file. The user is responsible for filling in the eventNumber field, which should be sequentially increasing integers starting with 0.- Throws:
java.io.IOException
-
write
public void write(long utime, java.lang.String channel, LCMEncodable msg) throws java.io.IOExceptionA convenience method for write. It internally manages the eventNumber field, and so calls to this method should not be mixed with calls to the other write methods.- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionCloses the log file and releases and system resources used by it.- Throws:
java.io.IOException
-
-