🧾 http_logger_plus

A developer-friendly HTTP logger for Dart that wraps http.Client and logs all requests and responses with formatting, cURL command generation, color-coded CLI output, and more.

πŸ” Perfect for debugging APIs, inspecting outgoing requests, and logging backend interactions in both CLI tools and Flutter apps.


pub version Dart CI License: MIT


✨ Features

  • βœ… Drop-in replacement for http.Client
  • 🧾 Pretty-printed request & response logs
  • 🎨 Color-coded terminal output
  • πŸŒ€ cURL command generation for any request
  • 🧼 Truncated body logging for large payloads
  • πŸ” Easy to extend with custom filters (coming soon)

πŸš€ Getting started

Add the dependency to your pubspec.yaml:

dependencies:
  http_logger_plus: ^0.0.1

πŸ“¦ Usage

void main() async {
  final client = HttpLoggerClient(http.Client());

  final response = await client.post(
    Uri.parse("https://jsonplaceholder.typicode.com/posts"),
    headers: {"Content-Type": "application/json; charset=utf-8"},
    body: '{"title": "test", "body": "content", "userId": 1}',
  );

  print("Actual response: ${response.body}");
}

πŸ§ͺ Example Log Output

🟦 [POST] https://jsonplaceholder.typicode.com/posts
Headers:
  Content-Type: application/json; charset=utf-8

πŸ’‘ curl -X POST "https://jsonplaceholder.typicode.com/posts" -H "Content-Type: application/json; charset=utf-8" -d '{"title": "test", "body": "content", "userId": 1}'

πŸ“€ Request Body:
{
  "title": "test",
  "body": "content",
  "userId": 1
}

⬇️ Response [201 Created] (407ms)
Response Body:
{
  "title": "test",
  "body": "content",
  "userId": 1,
  "id": 101
}

πŸ“‚ Example

You can find a complete example in the example/ directory.


πŸ“œ License

MIT License Β© 2025 Ayushman Pal

Libraries

http_logger_plus
Support for doing something awesome.