Skip to content

Put debug output to a file.#421

Merged
jacobsimionato merged 1 commit into
flutter:mainfrom
polina-c:test-main
Oct 22, 2025
Merged

Put debug output to a file.#421
jacobsimionato merged 1 commit into
flutter:mainfrom
polina-c:test-main

Conversation

@polina-c

@polina-c polina-c commented Oct 21, 2025

Copy link
Copy Markdown
Collaborator

Contributes to #31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the debug output to be saved to a file instead of printed to the console, which is a good improvement for debuggability. My main feedback is to ensure this file I/O only happens in debug mode to avoid side effects in release builds. Additionally, please note that this change makes the instructions for updating test data in examples/custom_backend/test/backend_api_test.dart outdated, as the response body is no longer printed to the console. The instructions in that file should be updated to reflect the new workflow of retrieving debug output from the generated files.


if (response.statusCode == 200) {
print('Response body: ${response.body}');
debugSaveToFileObject('response-body', response.body);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Debug code with side effects like file I/O should be guarded to only run in debug mode. This prevents creating debug files in release builds, which can be an unexpected side effect for users and could impact performance. Please wrap this call in an if (kDebugMode) block. You will also need to add import 'package:flutter/foundation.dart'; at the top of the file.

Suggested change
debugSaveToFileObject('response-body', response.body);
if (kDebugMode) {
debugSaveToFileObject('response-body', response.body);
}

@jacobsimionato jacobsimionato merged commit a6f9ca0 into flutter:main Oct 22, 2025
14 checks passed
gspencergoog pushed a commit to gspencergoog/genui that referenced this pull request Oct 22, 2025
@polina-c polina-c deleted the test-main branch October 26, 2025 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants