From cfa74b91063251b6d88ac7f65bbe1044ff67ffe6 Mon Sep 17 00:00:00 2001 From: Nicolas Martin Date: Fri, 17 Jan 2020 11:08:14 +0100 Subject: [PATCH] logger: choose logged instances by logger_topics file new versions of logger does not allow to log multiple instances of a topic when using 'logger_topics.txt' This commit restores the default behavior (log all instances of a topic) and ad the option to specify an instance to log --- src/modules/logger/logged_topics.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/logger/logged_topics.cpp b/src/modules/logger/logged_topics.cpp index ac18e1890a..4e95f94396 100644 --- a/src/modules/logger/logged_topics.cpp +++ b/src/modules/logger/logged_topics.cpp @@ -230,10 +230,11 @@ int LoggedTopics::add_topics_from_file(const char *fname) continue; } - // read line with format: [, ] + // read line with format: [ [ ]] char topic_name[80]; uint32_t interval_ms = 0; - int nfields = sscanf(line, "%s %u", topic_name, &interval_ms); + uint32_t instance = 0; + int nfields = sscanf(line, "%s %u %u", topic_name, &interval_ms, &instance); if (nfields > 0) { int name_len = strlen(topic_name); @@ -243,7 +244,8 @@ int LoggedTopics::add_topics_from_file(const char *fname) } /* add topic with specified interval_ms */ - if (add_topic(topic_name, interval_ms)) { + if ((nfields > 2 && add_topic(topic_name, interval_ms, instance)) + || add_topic_multi(topic_name, interval_ms)) { ntopics++; } else {