dio_pretty_logger 1.0.4
dio_pretty_logger: ^1.0.4 copied to clipboard
Pretty logger for DIO package
π± dio_pretty_logger #
A developer-friendly Dio interceptor that logs HTTP requests, responses, and errors in a clean and readable format. Useful for debugging API calls in Flutter/Dart projects.
β¨ Features #
- β Logs HTTP requests, responses, and errors.
- β Pretty print format with key metadata.
- β Lightweight and easy to integrate.
- β Fully customizable logging output.
π¦ Installation #
Add the package to your pubspec.yaml
:
dependencies:
dio_pretty_logger: ^latest_version
dependencies:
flutter pub get
π Usage #
import 'package:dio/dio.dart';
import 'package:dio_pretty_logger/dio_pretty_logger.dart';
final dio = Dio();
dio.interceptors.add(prettyInterceptorsWrapper);
if you want print raw Map or list use this functions
import 'package:dio_pretty_logger/dio_pretty_logger.dart';
var map = {
"key":"value",
};
DioPrettyLogger.printPrettyMap(map);
// For list
var list = [map];
DioPrettyLogger.printPrettyList(list);
π§ DioPrettyLogger Property Guide #
Property | Type | Default | Description |
---|---|---|---|
showRequest |
bool |
true |
Whether to log request basic info (method and URL). |
showRequestHeader |
bool |
true |
Whether to log request headers. |
showRequestBody |
bool |
true |
Whether to log the body (query params or payload) of the request. |
showResponseBody |
bool |
true |
Whether to log the response body. |
showResponseHeader |
bool |
false |
Whether to log response headers. |
showErrorMsg |
bool |
true |
Whether to log error messages on failed requests. |
compact |
bool |
true |
If true , will compact maps/lists when possible. |
maxWidth |
int |
90 |
Maximum character width before wrapping log lines. |
chunkSize |
int |
20 |
Chunk size for breaking up Uint8List log output. |
maxListPrintLength |
int |
2 |
Max items to show in a large list. 0 to disable limit. |
logPrint |
Function |
debugPrint |
Custom logging function. Only logs if kDioLogenable is true . |
kDioLogenable |
bool |
!kReleaseMode |
Whether logging is enabled. Usually disabled in release builds. |
tabStep |
String |
' ' |
Number of spaces used per indentation level. |
kInitialTab |
int |
1 |
Initial tab depth for nested structures. |
π License #
This project is licensed under the MIT License. See the LICENSE file for details.
π¬ Contributing #
Feel free to submit issues or pull requests. Contributions are welcome!
π Author #
Made with β€οΈ by Deepak.