Log files¶
UnmountedLog¶
- class canlib.kvmlib.UnmountedLog(memorator)[source]¶
The log area of a Memorator before mounting
Before the log area of a
Memorator
object has been mounted, itslog
attribute is set to an instance of this class.This class has all the functionality available even when the log area has not been mounted – this functionality is still present after the log area has been mounted (or if the area is always mounted – see
Kmf
).The number of log files can be read as the
len()
of this object (container
is either aMemorator
orKmf
object):num_log_files = len(container.log)
All log files can also be deleted:
container.log.delete_all()
New in version 1.6.
MountedLog¶
- class canlib.kvmlib.MountedLog(memorator, ldf_version)[source]¶
Bases:
canlib.kvmlib.log.UnmountedLog
The log area of a Memorator once mounted
Once a
Memorator
object has been mounted, itslog
attribute is set to an instance of this class. This is the preferred way of using this class.For
Kmf
objects, thelog
attribute is always an instance of this class as they are by definition mounted.In the following examples
container
can be either aMemorator
object that has been mounted, or aKmf
object.The files within the log can be accessed via indexing:
container.log[index]
or all files can be iterated over:
for log_file in container.log: ...
The log area can also be validated:
container.log.validate()
Also see the super class
UnmountedLog
for functionality this class has inherited.New in version 1.6.
LogFile¶
- class canlib.kvmlib.LogFile(container, index)[source]¶
A log file read from a
MountedLog
objectThis class is normally not directly instantiated but retrieved from a
MountedLog
object.The most common use of this class is iterating through it to get the individual events as
LogEvent
subclasses:for event in logfile: ...
Note
While iterating over a
LogFile
, accessing any otherLogFile
is will result in aLockedLogError
. Make sure to finish the loop (or when using iteration objects directly call theclose
method) before interacting with any other log files.A fast approximation of the number of events is given by
event_count_estimation
, the exact number of events can be calculated using:num_events = len(list(logfile))
Finally this class has several read-only properties for getting information about the log file itself.
Note
Before any data is fetched from the dll, this class will make sure that the correct file has been mounted on the underlying
kvmHandle
.Manually mounting or unmounting log files by calling the dll directly is not supported.
New in version 1.6.
- property creator_serial¶
The serial number of the interface that created the log file
- Type
int
- property end_time¶
The time of the last event in the log file
- Type
datetime.datetime
- event_count_estimation()[source]¶
Returns an approximation of the number of events
The number is a rough estimation because it is calculated from the number of blocks allocated by the log file on the disk as an optimization.
New in version 1.7.
- property log_type¶
The type of the log file
New in version 1.11.
- Type
- property start_time¶
The time of the first event in the log file
- Type
datetime.datetime