pretty_dio_logger 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

pretty_dio_logger #

Pretty Dio logger is a Dio interceptor that logs network calls in a pretty, easy to read format.

Usage #

Simply add PrettyDioLogger to your dio interceptors.

Dio dio = Dio();
dio.interceptors.add(PrettyDioLogger());
// customization
   dio.interceptors.add(PrettyDioLogger(
        requestHeader: true,
        requestBody: true,
        responseBody: true,
        responseHeader: false,
        error: true,
        compact: true,
        maxWidth: 90));

How it looks like #

VS Code #

Request Example Error Example

Android studio #

Response Example

[1.1.1] #

  • remove flutter as dependency

[1.1.0] #

fix #

  • remove ugly new lines from string values

[1.0.9] #

fix #

  • non string responses throw a mistype error (#4)

[1.0.8] #

change #

  • Update dio dependency to support dio 3.0.6 (#3).

[1.0.7] #

add #

  • log dio form data

[1.0.6] #

fix #

  • extra empty block when response logging is disabled (#2).
  • handle none response DioError types.

[1.0.5] #

add #

  • support for dio 3.0.3

[1.0.4] #

add #

  • support for dio 3.0.1
  • external logging

[1.0.3] #

add #

  • query parameters to logging;

[1.0.2+1] #

fix #

  • packaging typos.

[1.0.2] #

add #

  • support for dio 3.0.0

[1.0.1] #

add #

  • VSCode compatibility

[1.0.0] #

  • initial release.

example/README.md

import 'package:dio/dio.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';

void main() async {
  Dio dio = Dio();
  dio.interceptors.add(PrettyDioLogger(
    requestHeader: true,
    requestBody: true,
    responseBody: true,
    responseHeader: false,
    compact: false,
  ));

  try {
    await dio.get('http://www.mocky.io/v2/5d7fc75c3300000476f0b557');
  } catch (e) {
    print(e);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pretty_dio_logger: ^1.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pretty_dio_logger/pretty_dio_logger.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Fix lib/pretty_dio_logger.dart. (-5.84 points)

Analysis of lib/pretty_dio_logger.dart reported 12 hints, including:

line 84 col 11: DO use curly braces for all flow control structures.

line 107 col 9: DO use curly braces for all flow control structures.

line 143 col 9: DO use curly braces for all flow control structures.

line 149 col 9: DO use curly braces for all flow control structures.

line 179 col 7: DO use curly braces for all flow control structures.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
dio >=2.1.9 <=3.1.0 3.0.9
Transitive dependencies
charcode 1.1.3
collection 1.14.13
http_parser 3.1.4
meta 1.1.8
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0