talker_dio_logger 4.3.2 copy "talker_dio_logger: ^4.3.2" to clipboard
talker_dio_logger: ^4.3.2 copied to clipboard

Lightweight and customizable dio http client logger on talker base

talker_dio_logger #

Lightweight and customizable dio http client logger on talker base.
Talker - Advanced exception handling and logging for dart/flutter applications 🚀

GitHub codecov Pub License: MIT
talker talker_flutter talker_logger

Preview #

This is how the logs of your http requests will look in the console

For better understanding how it works check Web Demo page

Getting started #

Follow these steps to use this package

Add dependency #

dependencies:
  talker_dio_logger: ^4.3.2

Usage #

Just add TalkerDioLogger to your dio instance and it will work

final dio = Dio();
dio.interceptors.add(
    TalkerDioLogger(
        settings: const TalkerDioLoggerSettings(
          printRequestHeaders: true,
          printResponseHeaders: true,
          printResponseMessage: true,
        ),
    ),
);

Customization #

To provide hight usage exp here are a lot of settings and customization fields in TalkerDioLoggerSettings. You can setup all wat you want. For example:

Off/on http request or reposnse logs #

You can toggle reponse / request printing and headers including

final dio = Dio();
dio.interceptors.add(
    TalkerDioLogger(
        settings: const TalkerDioLoggerSettings(
          // All http responses enabled for console logging
          printResponseData: true,
          // All http requests disabled for console logging
          printRequestData: false,
          // Reposnse logs including http - headers
          printResponseHeaders: true,
          // Request logs without http - headersa
          printRequestHeaders: false,
        ),
    ),
);

Change http logs colors #

Setup your custom http-log colors. You can set color for requests, responses and errors in TalkerDioLoggerSettings

TalkerDioLoggerSettings(
  // Blue http requests logs in console
  requestPen: AnsiPen()..blue(),
  // Green http responses logs in console
  responsePen: AnsiPen()..green(),
  // Error http logs in console
  errorPen: AnsiPen()..red(),
);

Filter http logs #

For example if your app has a private functionality and you don't need to store this functionality logs in talker - you can use filters

TalkerDioLoggerSettings(
  // All http request without "/secure" in path will be printed in console 
  requestFilter: (RequestOptions options) => !options.path.contains('/secure'),
  // All http responses with status codes different than 301 will be printed in console 
  responseFilter: (response) => response.statusCode != 301,
)

Using with Talker #

You can add your talker instance for TalkerDioLogger if your app already uses Talker. In this case, all logs and errors will fall into your unified tracking system

final talker = Talker();
final dio = Dio();
dio.interceptors.add(TalkerDioLogger(talker: talker));

Additional information #

The project is under development and ready for your pull-requests and issues 👍
Thank you for support ❤️

104
likes
0
pub points
98%
popularity

Publisher

verified publisherfrezycode.com

Lightweight and customizable dio http client logger on talker base

Repository (GitHub)
View/report issues

Topics

#network #http #dio #logging

License

unknown (license)

Dependencies

dio, talker

More

Packages that depend on talker_dio_logger