Debugging using DevTool
To debug the code of the module created in Dart-IDE, you may use the logger of Dart-API and DevTool Module.
How to Use
Step 1. Import logger from the Dart-API at the top when developing code in Dart-IDE.
Step 2. Enter the logger.{Method Name}('text') in your code.
Step 3. Log remains as following when the code runs in Dart-Platform.
File path : C:\DART-Platform\logs\{today_date}.log
Step 4. An easier way to view logs is to use DevTool Module. Install the DevTool Module in Dart-Store.
Step 5. After running the DevTool module, you can click the collapse button in the upper right corner to float it above other modules you are debugging. Now, try debugging by checking the logs and errors.
Methods
The types of Logger are as following.
Method | Description | |
---|---|---|
1 | logger.debug | This method outputs a message to the log file at the "debug" log level. |
2 | logger.error | This method outputs a message to the log file at the "error" log level. |
3 | logger.info | This method outputs a message to the log file at the "info" log level. |
4 | logger.warn | This method outputs a message to the log file at the "warn" log level. |
Please refer to the https://apis.drdart.io/interfaces/dart_api.ILogger.html for more details.
Tips
How to check Object type value in the log file
When adding Object to the log as following, the result comes out like Log below.
Code
logger.debug(`Send current data: ${data}`);
Log
[2023-06-14 14:50:46.153][info ][DP] Send current data: [object Object]
In this case if you use JSON.stringify function as following, you may check the Object data in Json format in the Log as following.
Code
logger.debug(`Send current data : ${JSON.stringify(data)}`);
Log
[2023-06-14 14:50:46.153][info ][DP] Send current data: {"packageInfo":{"name":"Settings","packageName":"com.dart.module.settings"}}