dio_curl_logger_interceptor 1.0.1 copy "dio_curl_logger_interceptor: ^1.0.1" to clipboard
dio_curl_logger_interceptor: ^1.0.1 copied to clipboard

A simple dart package to help in logging HTTP requests using dio HTTP networking package

This package helps in debugging API requests using dio HTTP networking package

pub version pub likes GitHub Issues or Pull Requests GitHub Issues or Pull Requests

Features #

  • Works with app requests types (GET, POST, DELETE, PUT, OPTIONS, ...)
  • Works with app body types (Form data, Form URL encoded, Raw JSON, Raw text, ...)
  • Compatibility with Postman

If you would like to support me, buy me a coffee 🙃
HALF OF THE DONATIONS WILL GO TO GAZA, Free Palestine 🇵🇸
Buy Me A Coffee

Getting started #

attach the interceptor to a dio instance as follows, remember to keep the logging interceptor at last to log all headers & fields added from other interceptors

final dio = Dio();

dio.interceptors.add(DioCurlLoggerInterceptor());

Usage #

You can also have some customization as you want, you can:

  • Customize how to print the curl (by default using log from dart:developer)
  • You can determine whether to print the cURL onRequest or onResponse & onError see the following examples for more
// Customize how to print the curl
final dio = Dio();

// Write to a file for example:
final Directory directory = await getApplicationDocumentsDirectory();
final File file = File('${directory.path}/app_log.txt');

dio.interceptors.add(DioCurlLoggerInterceptor(onPrint: (final cURL) async {
  print('cURL is: $cURL');
  await file.writeAsString(cURL);
}));
// Determine when to print the cURL
final dio = Dio();

// [DEFAULT] this will print the cURL right before sending the the request to the server
dio.interceptors.add(DioCurlLoggerInterceptor(sendOnRequest: true));

// this will print the cURL once response arrive, either succeed or when exception happens
dio.interceptors.add(DioCurlLoggerInterceptor(sendOnRequest: false));

Contribution #

All contributions are welcome!

If you like this project then please click on the 🌟 it'll be appreciated or if you wanna add more epic stuff you can submit your pull request and it'll be gladly accepted 🙆‍♂️

or if you found any bug or issue do not hesitate opening an issue on github

0
likes
150
points
140
downloads

Publisher

verified publisherodeh-bros.com

Weekly Downloads

A simple dart package to help in logging HTTP requests using dio HTTP networking package

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter

More

Packages that depend on dio_curl_logger_interceptor