talker_dio_logger_plus 1.0.1 copy "talker_dio_logger_plus: ^1.0.1" to clipboard
talker_dio_logger_plus: ^1.0.1 copied to clipboard

Advanced and feature-rich Dio HTTP client logger with cURL export, JSON viewer, detail views, image support, and more

Talker Dio Logger Plus #

Advanced and feature-rich Dio HTTP client logger built on top of Talker. This package extends the basic talker_dio_logger with powerful features for debugging HTTP requests.

Features #

🚀 Core Features #

  • cURL Command Generation - Copy requests as cURL with option to hide sensitive data
  • Interactive JSON Viewer - Searchable, collapsible JSON viewer with syntax highlighting
  • Smart Truncation - Automatically truncate large payloads while preserving full data for detail view
  • Multi-format Response Support - JSON, HTML, Image, and plain text handling

🔒 Security Features #

  • Hidden Headers - Automatically hide sensitive headers like Authorization, API keys
  • Safe cURL Export - Export cURL commands with hidden auth tokens
  • Bearer Token Masking - Show Bearer ***** instead of actual token

🖼️ Content Type Handling #

  • JSON - Interactive viewer with search and syntax highlighting
  • Images - Inline preview for small images, tap to view for large images
  • HTML - Preview with option to view full rendered content
  • Text - Plain text display with full content support

📦 Export & Download #

  • Download as ZIP - Export request/response as a ZIP file (iOS/Android/Web compatible)
  • Share - Share logs via system share dialog
  • Copy - Copy individual sections or full cURL command
  • Pluggable File Saver - Customize or disable file saving behavior

📱 Detail View Features #

  • Tabbed Interface - Overview, Request, Response, and cURL tabs
  • Search in JSON - Find specific keys or values with highlighting
  • Full Headers View - See all request and response headers
  • Response Time - Track request duration

Installation #

Add to your pubspec.yaml:

dependencies:
  talker_dio_logger_plus: ^1.0.0

Quick Start #

import 'package:dio/dio.dart';
import 'package:talker_flutter/talker_flutter.dart';
import 'package:talker_dio_logger_plus/talker_dio_logger_plus.dart';

void main() {
  final talker = Talker();
  
  final logger = AdvancedDioLogger(
    talker: talker,
    settings: const AdvancedDioLoggerSettings(
      printRequestData: true,
      printResponseData: true,
      printResponseTime: true,
      hiddenHeaders: {'authorization', 'x-api-key'},
      hideAuthorizationValue: true,
    ),
  );
  
  final dio = Dio();
  dio.interceptors.add(logger);
}

Configuration #

AdvancedDioLoggerSettings #

AdvancedDioLoggerSettings(
  // Enable/Disable
  enabled: true,
  logLevel: LogLevel.debug,
  
  // Print settings
  printRequestData: true,
  printRequestHeaders: true,
  printRequestExtra: false,
  printResponseData: true,
  printResponseHeaders: true,
  printResponseMessage: true,
  printResponseTime: true,
  printErrorData: true,
  printErrorHeaders: true,
  printErrorMessage: true,
  
  // Security
  hiddenHeaders: {'authorization', 'x-api-key', 'api-key'},
  hideAuthorizationValue: true,
  
  // Truncation (in bytes)
  truncateThreshold: 100 * 1024,  // 100KB
  maxDisplaySize: 1024 * 1024,    // 1MB
  imagePreviewThreshold: 500 * 1024, // 500KB
  maxInlineJsonLines: 20,
  
  // Feature flags
  enableCurlGeneration: true,
  enableJsonViewer: true,
  enableImagePreview: true,
  enableHtmlPreview: true,
  enableDownload: true,
  
  // Custom file saver (optional)
  fileSaver: const DefaultFileSaver(), // or NoOpFileSaver() or custom
  
  // Filters
  requestFilter: (options) => true,
  responseFilter: (response) => true,
  errorFilter: (exception) => true,
)

Using with TalkerScreen #

To use the custom HTTP log cards in TalkerScreen:

TalkerScreen(
  talker: talker,
  itemsBuilder: (context, data) {
    if (isAdvancedHttpLog(data)) {
      return HttpLogCard(
        data: data,
        expanded: true,
      );
    }
    // Return default card for other log types
    return TalkerDataCard(
      data: data,
      color: data.getFlutterColor(theme),
      backgroundColor: theme.cardColor,
    );
  },
)

cURL Generation #

Copy cURL with Hidden Auth #

final log = data as AdvancedDioRequestLog;
final safeCurl = log.curlCommandSafe;
// Output: curl -X POST 'https://api.example.com' -H 'Authorization: Bearer [HIDDEN]'

Copy Full cURL #

final fullCurl = log.curlCommandFull;
// Output: curl -X POST 'https://api.example.com' -H 'Authorization: Bearer actual_token'

JSON Viewer #

The SearchableJsonViewer widget provides:

  • Expandable/collapsible nodes
  • Search with highlighting
  • Copy entire JSON
  • Syntax highlighting for different types

Custom File Saver #

The package provides a pluggable file saving system through FileSaverInterface. This allows you to:

  • Use the default implementation (DefaultFileSaver)
  • Disable file operations (NoOpFileSaver)
  • Provide your own custom implementation

Default Behavior #

By default, the package uses DefaultFileSaver which requires path_provider, archive, and share_plus packages.

Disable File Saving #

If you don't need file saving/sharing functionality:

final logger = AdvancedDioLogger(
  settings: AdvancedDioLoggerSettings(
    fileSaver: const NoOpFileSaver(),
  ),
);

Custom Implementation #

Create your own file saver by implementing FileSaverInterface:

class MyCustomFileSaver implements FileSaverInterface {
  @override
  Future<String?> saveToFile({
    required String filename,
    required dynamic data,
    String? directory,
  }) async {
    // Your custom save logic
  }

  @override
  Future<String?> saveHttpLogToZip(HttpLogData logData, {String? filename}) async {
    // Your custom ZIP creation logic
  }

  @override
  Future<void> shareFile({required String filepath, String? subject, String? text}) async {
    // Your custom share logic
  }

  @override
  Future<void> shareText(String text, {String? subject}) async {
    // Your custom text share logic
  }

  @override
  Future<void> saveAndShareHttpLog(HttpLogData logData) async {
    // Your custom save and share logic
  }

  @override
  Uint8List? getBytes(dynamic data) {
    // Convert data to bytes
  }
}

// Use it
final logger = AdvancedDioLogger(
  settings: AdvancedDioLoggerSettings(
    fileSaver: MyCustomFileSaver(),
  ),
);

Content Type Detection #

The logger automatically detects content types:

  • JSON: application/json, text/json
  • HTML: text/html, application/xhtml+xml
  • Images: image/jpeg, image/png, image/gif, etc.
  • XML: text/xml, application/xml
  • Text: text/plain

Size Handling #

Size Behavior
< 100KB Full display in list
100KB - 1MB Truncated in list, full in detail
> 1MB Truncated with download option
Images < 500KB Inline preview
Images > 500KB Tap to view

Platform Support #

Feature iOS Android Web
cURL Generation
JSON Viewer
Image Preview
Download ZIP ⚠️*
Share ⚠️*

*Web has limited file system access

License #

MIT License

3
likes
0
points
264
downloads

Publisher

unverified uploader

Weekly Downloads

Advanced and feature-rich Dio HTTP client logger with cURL export, JSON viewer, detail views, image support, and more

Repository (GitHub)
View/report issues

Topics

#dio #talker #logging

License

unknown (license)

Dependencies

archive, dio, flutter, http_parser, mime, path_provider, share_plus, talker, talker_flutter

More

Packages that depend on talker_dio_logger_plus