From 983c23b3a422b2ff15d595a3b43ebcba7fa2636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Thu, 5 Oct 2023 00:41:56 -0600 Subject: [PATCH] feat(taps): Log JSONPatch match count at the INFO level --- singer_sdk/helpers/jsonpath.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/singer_sdk/helpers/jsonpath.py b/singer_sdk/helpers/jsonpath.py index 9e2956f19..82c514b41 100644 --- a/singer_sdk/helpers/jsonpath.py +++ b/singer_sdk/helpers/jsonpath.py @@ -2,6 +2,7 @@ from __future__ import annotations +import logging import typing as t import memoization @@ -11,6 +12,9 @@ import jsonpath_ng +logger = logging.getLogger(__name__) + + def extract_jsonpath( expression: str, input: dict | list, # noqa: A002 @@ -27,7 +31,11 @@ def extract_jsonpath( compiled_jsonpath = _compile_jsonpath(expression) match: jsonpath_ng.DatumInContext - for match in compiled_jsonpath.find(input): + matches = compiled_jsonpath.find(input) + + logger.info("JSONPath matches: %d", len(matches)) + + for match in matches: yield match.value