efficient_dio_logger 0.3.0 copy "efficient_dio_logger: ^0.3.0" to clipboard
efficient_dio_logger: ^0.3.0 copied to clipboard

Not pretty, but efficient

example/main.dart

import 'dart:developer';

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

main() {
  Dio dio = Dio();
  dio.interceptors.add(EfficientDioLogger());

  // or customization:
  dio.interceptors.add(EfficientDioLogger(
    request: true,
    requestHeader: true,
    requestBody: true,
    responseHeader: false,
    responseBody: true,
    error: true,
    // set your console width
    lineWidth: 160,
    // set max content text length (Recommended use lineWidth*2)
    maxWidth: 320,
    // if true, value that has more than maxWidth(=320) characters will be truncated
    compact: true,
    // or use `print()`, may cause the log to be incomplete.
    logPrint: (l) => log('$l', name: 'EffLogger'),
    // or use `kDebugMode` (recommend)
    enabled: true,
    filter: (options, args) {
      // don't print requests with uris containing '/posts'
      if (options.path.contains('/posts')) {
        return false;
      }
      // don't print responses with unit8 list data
      // else, if compact=true, Uint8 list will be printed as 'Uint8List(length: maxWidth)'
      if (args.isResponse && args.hasUint8ListData) {
        return false;
      }
      return true;
    },
  ));
}
0
likes
140
points
63
downloads

Publisher

verified publisherwyattcoder.top

Weekly Downloads

Not pretty, but efficient

Repository (GitHub)

Topics

#dio #logging

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dio, flutter

More

Packages that depend on efficient_dio_logger