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

Not pretty, but efficient

Efficient Dio Logger / EffLogger #

Dio interceptor: not pretty, but efficient.

For projects using Dio and containing a large number of requests:

  • Print large payloads in a copy-friendly format.
  • Automatically truncate super long JSON values (image base64, avatar URL...) to avoid console overflow.

适用于使用 Dio 并且包含大量请求的项目:

  • 更适合复制和处理大体积请求/响应内容.
  • 自动截断超长 JSON value, 避免控制台溢出.

Installation #

dart pub add efficient_dio_logger

Usage #

Default recommendation: use EffDioLogger.

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

void main() {
  final dio = Dio();

  // Lightweight mode: keep the current compact EffDioLogger output.
  dio.interceptors.add(EffDioLogger());

  // Legacy-compatible mode: matches EfficientDioLogger(...) switches.
  dio.interceptors.add(EffDioLogger.compat(
    request: true,
    requestHeader: false,
    requestBody: false,
    responseHeader: false,
    responseBody: true,
    error: true,
    lineWidth: 160,
    maxWidth: 320,
    compact: true,
    enabled: true,
    logPrint: print,
    filter: (options, args) {
      if (options.path.contains('/posts')) {
        return false;
      }
      if (args.isResponse && args.hasUint8ListData) {
        return false;
      }
      return true;
    },
  ));
}

Modes #

  • EffDioLogger(): lightweight mode. This keeps the existing REQ/RSP/ERR style and is the default recommendation for new code.
  • EffDioLogger.compat(): legacy-compatible mode. Use this when migrating from EfficientDioLogger(...) without changing the old output switches.
  • EfficientDioLogger: deprecated, but still source-compatible. Internally it delegates to EffDioLogger.compat(...) so existing code can upgrade without changing constructor arguments.

Common options #

  • lineWidth configures the divider width used by compat mode.
  • maxWidth configures the maximum length of a single request/response value before truncation.
  • compact enables maxWidth truncation.
  • logLineBreak customizes line breaks for EffDioLogger output.
  • reqExtra, rspExtra, errExtra allow appending custom extra text.

Look Like #

img.png

Legacy alias #

typedef PrettyDioLogger = EfficientDioLogger;
2
likes
150
points
303
downloads

Documentation

API reference

Publisher

verified publisherwyattcoder.top

Weekly Downloads

Not pretty, but efficient

Repository (GitHub)
View/report issues

Topics

#dio #logging

License

BSD-3-Clause (license)

Dependencies

dio, flutter, logging

More

Packages that depend on efficient_dio_logger