"""
Generator function to iterate over the events of open in the current
TraceCollection.
+
+ Due to limitations of the native Babeltrace API, only one event
+ may be "alive" at a time (i.e. a user should never store a copy
+ of the events returned by this function for ulterior use). Users
+ shall make sure to copy the information they need from an event
+ before accessing the next one.
+
+ Furthermore, event objects become invalid when the generator goes
+ out of scope as the underlying iterator will be reclaimed. Using an
+ event after the the generator has gone out of scope may result in a
+ crash or data corruption.
"""
begin_pos_ptr = _bt_iter_pos()
end_pos_ptr = _bt_iter_pos()
CTFScope.STREAM_EVENT_HEADER, CTFScope.STREAM_PACKET_CONTEXT, CTFScope.TRACE_PACKET_HEADER]
import collections
+from datetime import datetime
class Event(collections.Mapping):
"""
This class represents an event from the trace.
"""
return _bt_ctf_get_timestamp(self._e)
+ @property
+ def datetime(self):
+ """
+ Return a datetime object based on the event's
+ timestamp. Note that the datetime class' precision
+ is limited to microseconds.
+ """
+ return datetime.fromtimestamp(self.timestamp / 1E9)
+
def field_with_scope(self, field_name, scope):
"""
Get field_name's value in scope.
def _field_list_with_scope(self, scope):
fields = []
scope_ptr = _bt_ctf_get_top_level_scope(self._e, scope)
-
+
# Returns a list [list_ptr, count]. If list_ptr is NULL, SWIG will only
# provide the "count" return value
count = 0