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

A comprehensive request tracking and exception logging library for Flutter applications, inspired by Spring Boot's MDC.

Request Tracker Logger #

A robust request tracking and exception logging library for Flutter applications, inspired by Spring Boot's Mapped Diagnostic Context (MDC).

Features #

  • Contextual Logging: Track logs with unique request IDs across asynchronous boundaries using Darts's Zone.
  • Dio Interceptor: Automatically track outgoing HTTP requests, log response times, and capture errors.
  • Global Exception Handling: Centralized handling for both Flutter framework errors and uncaught asynchronous errors.
  • Zero Configuration: Easy to set up and start tracking.

Installation #

Add request_tracker_logger to your pubspec.yaml:

dependencies:
  request_tracker_logger:
    git:
      url: https://github.com/DivyanshVish/request_tracker_logger.git

Usage #

1. Initialize Global Exception Handler #

In your main.dart, initialize the GlobalExceptionHandler before running the app:

import 'package:flutter/material.dart';
import 'package:request_tracker_logger/request_tracker_logger.dart';

void main() {
  GlobalExceptionHandler.initialize();
  runApp(const MyApp());
}

2. Using the Dio Interceptor #

Attach the RequestTrackingInterceptor to your Dio instance:

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

final dio = Dio();
dio.interceptors.add(RequestTrackingInterceptor());

3. Manual Contextual Logging #

You can run code within a specific logging context:

import 'package:request_tracker_logger/request_tracker_logger.dart';

RequestLogger.runWithContext(() {
  RequestLogger.info('Processing payment');
  // All logs inside this block will share the same UUID
}, userId: 'user_123', endpoint: '/pay');

License #

This project is licensed under the MIT License - see the LICENSE file for details.

1
likes
160
points
170
downloads

Publisher

verified publisherdivyanshdev.tech

Weekly Downloads

A comprehensive request tracking and exception logging library for Flutter applications, inspired by Spring Boot's MDC.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

cupertino_icons, dio, flutter, uuid

More

Packages that depend on request_tracker_logger