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

A local API request logger client package for Flutter/Dart applications.

net_logger #

A lightweight local network request logging client package for Flutter and Dart applications. It intercepts HTTP requests, responses, and errors, and streams them in real-time to the companion app net_logger_viewer for easy local debugging and analysis.

Features #

  • 🚀 Real-Time Streaming: Outgoing and incoming HTTP logs are streamed instantly to your local dashboard.
  • 📦 Dio Interceptor: Native support for Dio clients via NetLoggerInterceptor.
  • 🔗 http Client Wrapper: Support for standard Dart http packages via NetLoggerHttpClient.
  • 🔍 Detailed Telemetry: Captures methods, status codes, request/response headers, bodies, path parameters, execution duration, and stack traces on error.
  • ⚙️ Robust & Non-blocking: Logs are transmitted asynchronously in the background. Network issues, timeouts, or exceptions in sending telemetry are handled silently so they never disrupt your application's user experience.

Installation #

Add net_logger to your project's pubspec.yaml dependencies:

dependencies:
  net_logger: ^1.0.0

Run pub get in your terminal:

flutter pub get

Usage #

1. Integrating with Dio #

To log requests from a Dio instance, register NetLoggerInterceptor to its interceptors chain:

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

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

  dio.interceptors.add(
    NetLoggerInterceptor(
      appName: 'Flutter Client App', // Identifies this app in the viewer
      serverUrl: 'http://localhost:8080', // Address of the net_logger_viewer app
    ),
  );

  // Trigger requests normally
  dio.get('https://jsonplaceholder.typicode.com/posts/1');
}

2. Integrating with the standard http package #

For the http package, wrap your standard client inside a NetLoggerHttpClient:

import 'package:http/http.dart' as http;
import 'package:net_logger/net_logger.dart';

Future<void> makeRequest() async {
  // Wrap standard http.Client
  final client = NetLoggerHttpClient(
    http.Client(),
    appName: 'Flutter Client App',
    serverUrl: 'http://localhost:8080',
  );

  try {
    // Use it like a standard http client
    final response = await client.get(Uri.parse('https://jsonplaceholder.typicode.com/todos/1'));
    print('Response status: ${response.statusCode}');
  } finally {
    client.close(); // Closes the underlying client
  }
}

Companion Dashboard App #

To view the logged requests, run the companion application net_logger_viewer located in the root repository. By default, it opens a local HTTP server on port 8080 and displays a premium web/desktop dashboard that lets you search and filter logs by status code, HTTP method, app origin, and timestamps.

1
likes
0
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

A local API request logger client package for Flutter/Dart applications.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, http

More

Packages that depend on net_logger