igloo_http_logger 1.2.0
igloo_http_logger: ^1.2.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.
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: trueprints a copy-pasteable cURL command after each request - 🪪 Request ID tracking — bold cyan
│ ID: #xxxxon every request/response/error block for easy correlation of concurrent requests - 📋 Multipart form data preview —
http.MultipartRequestbodies logFields:andFiles:metadata (name, filename, content-type) - 🔍 GraphQL support — requests with a
querykey render as a dedicated[GraphQL]block with query and variables sections - ⚡ Zero performance impact in release mode (only logs in debug mode)
📸 Screenshots #
Request Logging #

Response Logging #

List Response (with Items count) #

cURL Logging (opt-in) #

Multipart Form Data Preview #

GraphQL Support #

Request ID Tracking #
Every request, response, and error block shows a bold cyan │ ID: #xxxx suffix. The 4-hex ID is auto-generated per request, making it easy to match logs from concurrent calls:

How to use it: When you see an unexpected response in the console, note its
ID:value and search upward for the matching request block with the same ID. No configuration needed — IDs are generated automatically.
Error Logging #

🚀 Getting Started #
Installation #
Add to your pubspec.yaml:
dependencies:
igloo_http_logger: ^1.2.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!