qa_logger

Creator: coderz1093

Last updated:

0 purchases

qa_logger Image
qa_logger Images
Add to Cart

Description:

qa logger

qa_logger #
qa_logger is a Dart package that provides a simple and efficient way to monitor network calls and logs in your application. It's a good tool for QA and backend developers.





Features #

Easy integration with Dio
Detailed logging of network requests and responses
Helps in identifying network-related issues

Installation #
Add qa_logger to your pubspec.yaml file:
dependencies:
qa_logger: $currentVersion$
copied to clipboard
Then run flutter pub get.
Usage #
Import qa_logger in your Dart file:
import 'package:qa_logger/qa_logger.dart';
copied to clipboard
Add the QAInterceptor to your Dio instance:
if (Kproduction == false) {
dio.interceptors.add(QaLogger().dioInterceptor);
}
copied to clipboard
Now, all network requests and responses made by the Dio instance will be logged by the QAInterceptor.
By default, the server will run on port 3000. If you want to change the port, you can add the following configuration in main.dart:
QaLogger.configure(port: 3001, wsPort: 8001);
copied to clipboard
API for Getting Logs #
The qa_logs package provides an API for getting logs by overriding the debugPrint function. This allows you to log messages using the QaLogger class, which will automatically log the messages to the localhost:3000 server.
Here's how you can override the debugPrint function:
debugPrint = (message, {wrapWidth}) {
if (Kproduction == true) return;
QaLogger().log(message);
if (message != null) {
log(message, name: 'DebugPrint');
}
};
copied to clipboard
Handling Flutter Errors #
In addition to logging debug messages, qa_logs can also be used to log Flutter errors. You can override the FlutterError.onError function to log error details using the QaLogger class:
FlutterError.onError = (FlutterErrorDetails details) {
if (Kproduction == true) return;
QaLogger().logError(details.toString());
};
copied to clipboard
With this setup, any calls to debugPrint in your application will be logged by the QaLogger and can be viewed on localhost:3000.
Viewing Logs #
To view the logs, open localhost:3000 on your device.
If you want to view the logs on your laptop, ensure that your device and laptop are connected to the same WiFi network. Then, open the browser on your laptop and enter the IP address of the application running device (you can get ip from localhost:3000 also) followed by port 3000.
For example, if the IP address of your device is 192.168.1.5, you would enter 192.168.1.5:3000 in your browser.
This will allow you to monitor the network calls of your application in real-time.
Viewing logs from the Android Emulator on a PC browser #
To view the logs from an Android emulator, you need to forward the necessary ports using the Android Debug Bridge (adb) tool.
Run the following commands:
adb forward tcp:3000 tcp:3000
adb forward tcp:<ws_port> tcp:<ws_port>
copied to clipboard
note: Replace <ws_port> with the port number that is displayed in the localhost:3000 page.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.