Skip to content

Commit b89ad62

Browse files
Reduce log noise for duplicate-but-same-value result entries
1 parent 7994d5e commit b89ad62

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/geophires_x_client/geophires_x_result.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,21 @@ def _get_result_field(self, field_name: str, is_string_value_field: bool = False
434434
return None
435435

436436
if len(matching_lines) > 1:
437-
self._logger.warning(
438-
f'Found multiple ({len(matching_lines)}) entries for field: {field_name}\n\t{matching_lines}'
439-
)
437+
438+
def normalize_spaces(matched_line):
439+
return re.sub(r'\s+', r' ', matched_line)
440+
441+
if len({normalize_spaces(_) for _ in matching_lines}) > 1:
442+
# TODO maybe this should throw a RuntimeError...
443+
self._logger.error(
444+
f'Found multiple ({len(matching_lines)}) entries for field with different values: '
445+
f'{field_name}\n\t{matching_lines}'
446+
)
447+
else:
448+
self._logger.debug(
449+
f'Found multiple ({len(matching_lines)}) entries for field with same value: '
450+
f'{field_name}\n\t{set(matching_lines)}'
451+
)
440452

441453
matching_line = matching_lines.pop()
442454
val_and_unit_str = re.sub(r'\s\s+', '', matching_line.replace(f'{field_name}:', '').replace('\n', ''))

0 commit comments

Comments
 (0)