Babeltrace 1's babeltrace-log(1) has a -t option to extract timestamps
and write them to the event headers. It makes more sense to extract them
by default in the component itself, but babeltrace-log(1) can pass
no-extract-timestamp=yes when -t is not provided.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
struct {
GString *path;
bt_bool read_from_stdin;
struct {
GString *path;
bt_bool read_from_stdin;
} params;
struct bt_ctf_trace *trace;
} params;
struct bt_ctf_trace *trace;
int handle_params(struct dmesg_component *dmesg_comp, struct bt_value *params)
{
struct bt_value *read_from_stdin = NULL;
int handle_params(struct dmesg_component *dmesg_comp, struct bt_value *params)
{
struct bt_value *read_from_stdin = NULL;
+ struct bt_value *no_timestamp = NULL;
struct bt_value *path = NULL;
const char *path_str;
int ret = 0;
struct bt_value *path = NULL;
const char *path_str;
int ret = 0;
+ no_timestamp = bt_value_map_get(params, "no-extract-timestamp");
+ if (no_timestamp) {
+ if (!bt_value_is_bool(no_timestamp)) {
+ BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
+ "type=%s",
+ bt_value_type_string(
+ bt_value_get_type(no_timestamp)));
+ goto error;
+ }
+
+ ret = bt_value_bool_get(no_timestamp,
+ &dmesg_comp->params.no_timestamp);
+ assert(ret == 0);
+ }
+
path = bt_value_map_get(params, "path");
if (path) {
if (dmesg_comp->params.read_from_stdin) {
path = bt_value_map_get(params, "path");
if (path) {
if (dmesg_comp->params.read_from_stdin) {
end:
bt_put(read_from_stdin);
bt_put(path);
end:
bt_put(read_from_stdin);
bt_put(path);
assert(user_field);
*new_start = line;
assert(user_field);
*new_start = line;
+ if (dmesg_comp->params.no_timestamp) {
+ goto skip_ts;
+ }
+
/* Extract time from input line */
if (sscanf(line, "[%lu.%lu] ", &sec, &usec) == 2) {
ts = (uint64_t) sec * USEC_PER_SEC + (uint64_t) usec;
/* Extract time from input line */
if (sscanf(line, "[%lu.%lu] ", &sec, &usec) == 2) {
ts = (uint64_t) sec * USEC_PER_SEC + (uint64_t) usec;
/*
* At this point, we know if the stream class's event header
* field type should have a timestamp or not, so we can lazily
/*
* At this point, we know if the stream class's event header
* field type should have a timestamp or not, so we can lazily