Put debug output to a file.#421
Conversation
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
| debugSaveToFileObject('response-body', response.body); | |
| if (kDebugMode) { | |
| debugSaveToFileObject('response-body', response.body); | |
| } |
Contributes to #31