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

A beautiful HTTP request/response logger for the http package with ANSI colors, emojis, and advanced filtering options.

Igloo HTTP Logger 🎨 #

A beautiful HTTP request/response logger for the http package with ANSI colors, emojis, and advanced filtering options.

Igloo HTTP Logger License

Also using Dio? Check out igloo_dio_logger — the companion package with the same beautiful output.

✨ Features #

  • 🎨 Beautiful colored output with ANSI colors
  • 😀 Emoji status indicators for HTTP status codes
  • 📊 Request/Response sizes in human-readable format (B, KB, MB, GB)
  • ⏱️ Duration tracking for each request
  • 🔍 Advanced filtering options:
    • Filter by endpoints (include/exclude patterns)
    • Log only errors (4xx, 5xx)
    • Log only slow requests (minimum duration)
  • 📦 Pretty JSON formatting with syntax highlighting
  • 🔢 Array item annotations — each item labeled // [0], // [1], with nested array support
  • 📋 Items count in the status line for List responses and common wrapper keys like data, users, results (Items: 42)
  • 🎯 Smart header wrapping for long values (like JWT tokens)
  • 🔗 cURL logging — opt-in logCurl: true prints a copy-pasteable cURL command after each request
  • Zero performance impact in release mode (only logs in debug mode)

📸 Screenshots #

Request Logging #

╔═══ 🚀 HTTP REQUEST ═══════════════════════════════════════════════
║ POST /api/v1/auth/login │ 156B
║
║ Headers:
║   content-type: application/json
║   authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
║
║ Body:
║   {
║     "email": "user@example.com",
║     "password": "********"
║   }
╚═══════════════════════════════════════════════════════════════════

Response Logging #

╔═══ ✅ HTTP RESPONSE ══════════════════════════════════════════════
║ POST /api/v1/auth/login
║ Status: 200 ✅ │ Duration: 245ms │ Size: 1.24KB
║
║ Body:
║   {
║     "success": true,
║     "data": {
║       "user": {
║         "id": "123",
║         "email": "user@example.com"
║       }, // user
║       "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
║     } // data
║   }
╚═══════════════════════════════════════════════════════════════════

List Response (with Items count) #

╔═══ ✅ HTTP RESPONSE ══════════════════════════════════════════════
║ GET /api/v1/users
║ Status: 200 ✅ │ Duration: 112ms │ Size: 2.48KB │ Items: 3
║
║ Body:
║   [
║     {
║       "id": "1",
║       "name": "Alice"
║     }, // [0]
║     {
║       "id": "2",
║       "name": "Bob"
║     }, // [1]
║     {
║       "id": "3",
║       "name": "Charlie"
║     } // [2]
║   ]
╚═══════════════════════════════════════════════════════════════════

cURL Logging (opt-in) #

╔═══ 🔗 cURL ═══════════════════════════════════════════════════════
║ # bash/zsh/fish
║ curl \
║   -L \
║   -X POST \
║   -H 'content-type: application/json' \
║   -H 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
║   -d '{"email":"user@example.com","password":"secret"}' \
║   'https://api.example.com/auth/login'
╚═══════════════════════════════════════════════════════════════════

MultipartRequest (form data)

╔═══ 🔗 cURL ═══════════════════════════════════════════════════════
║ # bash/zsh/fish
║ curl \
║   -L \
║   -X POST \
║   --form 'name=Alice' \
║   --form 'avatar=@"profile.jpg"' \
║   'https://api.example.com/users'
╚═══════════════════════════════════════════════════════════════════

File fields show the filename as a placeholder (@"filename"). Replace with the full path on your machine: --form 'avatar=@"/Users/alice/profile.jpg"'

StreamedRequest

╔═══ 🔗 cURL ═══════════════════════════════════════════════════════
║ # bash/zsh/fish
║ # ⚠️  Streamed body — body bytes not available at log time
║ curl \
║   -L \
║   -X POST \
║   -H 'content-type: application/octet-stream' \
║   'https://api.example.com/upload'
╚═══════════════════════════════════════════════════════════════════

Error Logging #

╔═══ ❌ HTTP ERROR ═════════════════════════════════════════════════
║ GET /api/v1/users/999
║ ClientException │ Duration: 89ms
║ Connection refused
╚═══════════════════════════════════════════════════════════════════

🚀 Getting Started #

Installation #

Add to your pubspec.yaml:

dependencies:
  igloo_http_logger: ^1.1.0

Run:

flutter pub get

Basic Usage #

import 'package:igloo_http_logger/igloo_http_logger.dart';

// Create the logger client (wraps a default http.Client)
final client = IglooHttpLogger();

// Use just like a normal http.Client
final response = await client.get(Uri.parse('https://api.example.com/users'));

// Always close when done
client.close();

With a Custom Inner Client #

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

final client = IglooHttpLogger(client: http.Client());

Advanced Configuration #

final client = IglooHttpLogger(
  // Show/hide different parts of the log
  logRequestHeader: true,
  logRequestBody: true,
  logResponseHeader: false,
  logResponseBody: true,
  logErrors: true,

  // Control the width of the log output
  maxWidth: 90,

  // Filter by endpoints (regex patterns)
  includeEndpoints: [r'/api/v1/auth/.*', r'/api/v1/users/.*'],
  excludeEndpoints: [r'/api/v1/health'],

  // Only log errors (4xx, 5xx status codes)
  onlyErrors: false,

  // Only log slow requests (in milliseconds)
  slowRequestThresholdMs: 200,
);

🎯 Configuration Options #

Option Type Default Description
client http.Client? http.Client() Inner HTTP client to delegate requests to
logRequestHeader bool true Show request headers
logRequestBody bool true Show request body
logResponseHeader bool false Show response headers
logResponseBody bool true Show response body
logErrors bool true Show errors
logCurl bool false Print a copy-pasteable cURL command after each request
maxWidth int 90 Maximum width of log output
includeEndpoints List<String>? null Only log matching endpoints (regex)
excludeEndpoints List<String>? null Exclude matching endpoints (regex)
onlyErrors bool false Only log error responses (4xx, 5xx)
slowRequestThresholdMs int? null Only log requests slower than X ms

📋 Examples #

Filter Specific Endpoints #

final client = IglooHttpLogger(
  includeEndpoints: [r'/auth/.*', r'/users/.*'],
);

Log Only Errors #

final client = IglooHttpLogger(onlyErrors: true);

Log Only Slow Requests #

final client = IglooHttpLogger(slowRequestThresholdMs: 500);

Log cURL Commands #

Enable logCurl: true to print a ready-to-paste cURL command after every request. The cURL block uses the same ╔═══ ... ╚═══ bordered style as request/response logs.

final client = IglooHttpLogger(logCurl: true);

Body handling at a glance:

Request type cURL output
http.Request (JSON/text body) -d '{"key":"value"}'
http.MultipartRequest (text fields) --form 'key=value' per field
http.MultipartRequest (file fields) --form 'key=@"filename"' — replace with full path
http.StreamedRequest Body omitted + ⚠️ note: "body bytes not available at log time"

Windows users: cURL syntax uses bash \ line continuation and single-quoted values. Run in WSL, Git Bash, or adapt manually: \^, '...'"..." with \" escaping.

Production-Safe Setup #

import 'package:flutter/foundation.dart';

final client = IglooHttpLogger(
  logRequestBody: kDebugMode,
  logResponseBody: kDebugMode,
  onlyErrors: !kDebugMode,
);

🎨 Status Code Emojis #

2xx Success #

  • ✅ 200 OK
  • ✨ 201 Created
  • ⏳ 202 Accepted
  • ⭕ 204 No Content

3xx Redirection #

  • ↪️ 301 Moved Permanently
  • 🔄 302 Found
  • 📦 304 Not Modified

4xx Client Errors #

  • ⚠️ 400 Bad Request
  • 🔒 401 Unauthorized
  • 🚫 403 Forbidden
  • 🔍 404 Not Found
  • 🚷 405 Method Not Allowed
  • ⏱️ 408 Request Timeout
  • ⚔️ 409 Conflict
  • 📋 422 Unprocessable Entity
  • 🚦 429 Too Many Requests

5xx Server Errors #

  • 💥 500 Internal Server Error
  • 🚧 502 Bad Gateway
  • 🔴 503 Service Unavailable
  • ⌛ 504 Gateway Timeout

🤝 Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License #

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

👨‍💻 Author #

Created with ❤️ by Akhilesh

🙏 Acknowledgments #

  • Inspired by igloo_dio_logger
  • ANSI color codes for beautiful terminal output
  • Emojis for quick visual status recognition

📚 Additional Resources #


If you find this package useful, please give it a ⭐ on GitHub and a 👍 on pub.dev!

2
likes
160
points
104
downloads

Documentation

API reference

Publisher

verified publisherigloodev.in

Weekly Downloads

A beautiful HTTP request/response logger for the http package with ANSI colors, emojis, and advanced filtering options.

Repository (GitHub)
View/report issues

Topics

#http #logging #networking #debugging

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on igloo_http_logger