summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaya Sugiura <ssugiura@jp.adit-jv.com>2019-11-28 11:03:39 +0900
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2020-07-06 10:04:07 +0900
commit048c3d9fdfdb1a7e5ed45cc0d55b9f9389fdb6bb (patch)
tree4055beeb12b2fc4d113787dc8ff3dad0cac0f5e3
parent43b2f7bf579858bf66511d38340f8436d5d1363d (diff)
downloadDLT-daemon-048c3d9fdfdb1a7e5ed45cc0d55b9f9389fdb6bb.tar.gz
logstorage: Filter section handling
When following filter is used, dlt-daemon gives an error message even it's using optional sections: NON-VERBOSE-STORAGE-FILTER NON-VERBOSE-LOGLEVEL-CTRL This commit fixes to check if the section is optional or not and just gives debug message if it's optional. Also, new static function is introduced to harmonize all the behavior in logstorage filter. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
-rw-r--r--src/offlinelogstorage/dlt_offline_logstorage.c101
1 files changed, 48 insertions, 53 deletions
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c
index 872c47e..b98e4ee 100644
--- a/src/offlinelogstorage/dlt_offline_logstorage.c
+++ b/src/offlinelogstorage/dlt_offline_logstorage.c
@@ -1275,6 +1275,41 @@ DLT_STATIC int dlt_logstorage_check_param(DltLogStorageFilterConfig *config,
return -1;
}
+DLT_STATIC int dlt_logstorage_get_filter_section_value(DltConfigFile *config_file,
+ char *sec_name,
+ DltLogstorageFilterConf entry,
+ char *value)
+{
+ int ret = 0;
+
+ if ((config_file == NULL) || (sec_name == NULL))
+ return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+
+ if (entry.key != NULL) {
+ ret = dlt_config_file_get_value(config_file, sec_name,
+ entry.key,
+ value);
+
+ if ((ret != 0) && (entry.is_opt == 0)) {
+ dlt_vlog(LOG_WARNING,
+ "Invalid configuration in section: %s -> %s : %s\n",
+ sec_name, entry.key, value);
+ return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+ }
+
+ if ((ret != 0) && (entry.is_opt == 1)) {
+ dlt_vlog(LOG_DEBUG, "Optional parameter %s not specified\n",
+ entry.key);
+ return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
+ }
+ }
+ else {
+ return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
+ }
+
+ return 0;
+}
+
DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
char *sec_name,
int index,
@@ -1292,70 +1327,30 @@ DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
if (strncmp(sec_name,
DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
config_sec_len) == 0) {
- if (filter_cfg_entries[index].key != NULL) {
- ret = dlt_config_file_get_value(config_file, sec_name,
- filter_cfg_entries[index].key,
- value);
-
- if ((ret != 0) && (filter_cfg_entries[index].is_opt == 0)) {
- dlt_vlog(LOG_WARNING,
- "Invalid configuration in section: %s -> %s : %s\n",
- sec_name, filter_cfg_entries[index].key, value);
- return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
- }
-
- if ((ret != 0) && (filter_cfg_entries[index].is_opt == 1)) {
- dlt_vlog(LOG_DEBUG, "Optional parameter %s not specified\n",
- filter_cfg_entries[index].key);
- return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
- }
- }
- else {
- return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
- }
+ ret = dlt_logstorage_get_filter_section_value(config_file, sec_name,
+ filter_cfg_entries[index],
+ value);
}
else if (strncmp(sec_name,
DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION,
- storage_sec_len) == 0)
- {
- if (filter_nonverbose_storage_entries[index].key != NULL) {
- if (dlt_config_file_get_value(config_file, sec_name,
- filter_nonverbose_storage_entries[index].key, value) != 0) {
- dlt_vlog(LOG_WARNING,
- "Invalid configuration in section: %s -> %s : %s\n",
- sec_name, filter_nonverbose_storage_entries[index].key,
- value);
- return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
- }
- }
- else {
- return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
- }
+ storage_sec_len) == 0) {
+ ret = dlt_logstorage_get_filter_section_value(config_file, sec_name,
+ filter_nonverbose_storage_entries[index],
+ value);
}
else if ((strncmp(sec_name,
DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION,
- control_sec_len) == 0))
- {
- if (filter_nonverbose_control_entries[index].key != NULL) {
- if (dlt_config_file_get_value(config_file, sec_name,
- filter_nonverbose_control_entries[index].key, value) != 0) {
- dlt_vlog(LOG_WARNING,
- "Invalid configuration in section: %s -> %s : %s\n",
- sec_name, filter_nonverbose_control_entries[index].key,
- value);
- return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
- }
- }
- else {
- return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
- }
+ control_sec_len) == 0)) {
+ ret = dlt_logstorage_get_filter_section_value(config_file, sec_name,
+ filter_nonverbose_control_entries[index],
+ value);
}
else {
dlt_log(LOG_ERR, "Error: Section name not valid \n");
- return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+ ret = DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
}
- return 0;
+ return ret;
}
DLT_STATIC int dlt_logstorage_setup_table(DltLogStorage *handle,