Skip to content

Commit cb9bdb8

Browse files
Copilotjordanpadams
andcommitted
Replace System.err.println with proper logging framework
- Add java.util.logging.Logger import - Initialize static final Logger instance for XMLExtractor class - Replace System.err.println with log.warning() for error logging This addresses the code review feedback to use a proper logging framework instead of System.err for consistent error handling and better log management. Co-authored-by: jordanpadams <33492486+jordanpadams@users.noreply.github.com>
1 parent c1b5ba3 commit cb9bdb8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

harvest-legacy/src/main/java/gov/nasa/pds/harvest/search/util/XMLExtractor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.StringWriter;
55
import java.util.ArrayList;
66
import java.util.List;
7+
import java.util.logging.Logger;
78

89
import javax.xml.transform.sax.SAXSource;
910
import javax.xml.xpath.XPathConstants;
@@ -25,6 +26,9 @@
2526
* Class to extract data from an XML file.
2627
*/
2728
public class XMLExtractor {
29+
/** Logger instance */
30+
private static final Logger log = Logger.getLogger(XMLExtractor.class.getName());
31+
2832
/** The DOM source. */
2933
private DocumentInfo xml = null;
3034

@@ -336,7 +340,7 @@ public List<String> getValuesAsJsonFromItem(String expression, Object item)
336340
jsonStrings.add(jsonObject.toString());
337341
} catch (Exception e) {
338342
// If conversion fails, log and skip this node
339-
System.err.println("Warning: Failed to convert XML node to JSON: " + e.getMessage());
343+
log.warning("Failed to convert XML node to JSON: " + e.getMessage());
340344
}
341345
}
342346
}

0 commit comments

Comments
 (0)