Skip to main content

dio_logging_interceptor_v2 1.1.0 copy "dio_logging_interceptor_v2: ^1.1.0" to clipboard
dio_logging_interceptor_v2: ^1.1.0 copied to clipboard

A Dio interceptor which logs HTTP request and response data without truncation

example/main.dart

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

void main() async {
  final dio = Dio(
    BaseOptions(
      baseUrl: 'https://jsonplaceholder.typicode.com',
      headers: {
        'Authorization': 'Bearer secret_user_token_123',
      },
    ),
  );

  dio.interceptors.add(
    DioLoggingInterceptor(
      level: Level.body,
      compact: false,
      logDuration: true,
      logCurl: true,
      enableColors: true,
      maskedHeaders: ['authorization'],
      maskedBodyFields: ['password', 'token'],
      ignorePaths: ['/health'],
    ),
  );

  print('\n--- 1. Testing GET with JSON Array response ---');
  try {
    await dio.get('/posts', queryParameters: {'_limit': 2});
  } catch (e) {
    print('Error: $e');
  }

  print('\n--- 2. Testing POST with Sensitive Body Masking ---');
  try {
    await dio.post(
      '/posts',
      data: {
        'title': 'foo',
        'body': 'bar',
        'userId': 1,
        'password': 'mySecretPassword123',
      },
    );
  } catch (e) {
    print('Error: $e');
  }
}
0
likes
140
points
192
downloads

Documentation

API reference

Publisher

verified publisherrizkyghofur.my.id

Weekly Downloads

A Dio interceptor which logs HTTP request and response data without truncation

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dio

More

Packages that depend on dio_logging_interceptor_v2