Replace System.out/err.println with logging in analysis and test code#332
Replace System.out/err.println with logging in analysis and test code#332
Conversation
…(part 1) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
…files (part 2) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
…ngines (part 3) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
…es (part 4) Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
|
@copilot Do we also use logging in test files? If so, then perhaps it is appropriate to also refactor print statements in test files to use logging. |
Co-authored-by: khatchad <2048831+khatchad@users.noreply.github.com>
Yes, the codebase already uses logging in test files. Analysis showed some test files like TestCalls.java already had proper logger setup, indicating an incomplete migration. I've refactored key test files to use consistent logging patterns, replacing ~4 instances across TestClasses.java, TestCalls.java, TestSource.java, and TestPythonMLCallGraphShape.java. The changes use LOGGER.info() for test results and LOGGER.fine() for detailed debug output, providing better control over test output through logging configuration. Commit: c3197c6 |
This PR refactors the codebase to replace
System.out.println()andSystem.err.println()statements with proper logging in non-CLI analysis, processing, and test code, while preserving appropriate print statements in CLI-related functionality.Changes Made
Refactored 37 instances across key analysis components and test files:
PythonCAstToIRTranslator,PythonTurtleSKLearnClassifierAnalysis,PythonTurtlePandasMergeAnalysis, andPythonSSAPropagationCallGraphBuilderTensorTypeand error logging inCloudFunctionPythonParserclassesPytestLoaderandPython2LoaderPytestAnalysisEngineParquetPythonReaderTestClasses.java,TestCalls.java,TestSource.java, andTestPythonMLCallGraphShape.javaEstablished consistent logging patterns:
private static final Logger LOGGER = Logger.getLogger(ClassName.class.getName());LOGGER.fine()for debug information,LOGGER.info()for status messages,LOGGER.severe()for errorsjava.util.loggingPreserved CLI-appropriate usage:
Ariadne.javamain method error handling and user messagesDiagnosticsFormatter.javaprint methods for user-facing outputshowMessage()methods for user communicationExample
Before:
After:
The changes improve code maintainability by centralizing logging configuration and allowing proper log level control throughout both production and test code, while maintaining all existing CLI functionality for end users.
Fixes #331.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.