pretty_dio_clean_logger 1.0.0
pretty_dio_clean_logger: ^1.0.0 copied to clipboard
A clean and customizable Dio logger that prints beautifully formatted request, response, and error logs with filtering support.
pretty_dio_clean_logger #
A clean and customizable logging interceptor for Dio that prints beautifully formatted request, response, and error logs. It includes pretty_dio_clean_logger, a cleaner and more refined version of pretty_dio_logger.
✨ Features #
- ✅ Pretty formatted request & response logs
- ✅ JSON (Map & List) pretty printing
- ✅ Support for FormData & file uploads
- ✅ Request/Response headers logging
- ✅ Response time tracking
- ✅ Error logging with details
- ✅ Custom log printer support
- ✅ Powerful filtering system
- ✅ Enable/disable logs easily
- ✅ Compact & readable output
Usage #
Simply add PrettyDioCleanLogger to your dio interceptors.
Dio dio = Dio();
dio.interceptors.add(PrettyDioCleanLogger());
// customization
dio.interceptors.add(PrettyDioCleanLogger(
requestHeader: true,
requestBody: true,
responseBody: true,
responseHeader: false,
error: true,
compact: true,
maxWidth: 90,
enabled: kDebugMode,
filter: (options, args){
// don't print requests with uris containing '/posts'
if(options.path.contains('/posts')){
return false;
}
// don't print responses with unit8 list data
return !args.isResponse || !args.hasUint8ListData;
}
)
);
📸 Example Output #
┌┤ Request │ POST
│ https://api.example.com/login
├────────────────────────────────────────────
│ Headers:
│ Authorization: Bearer token
├────────────────────────────────────────────
│ Body:
│ {
│ "email": "user@email.com",
│ "password": "******"
│ }
└────────────────────────────────────────────
┌┤ Response │ POST │ Status: 200 OK │ Time: 245 ms
│ https://api.example.com/login
├────────────────────────────────────────────
│ Headers:
│ content-type: application/json
│ cache-control: no-cache
├────────────────────────────────────────────
│ Body:
│ {
│ "success": true,
│ "message": "Login successful",
│ "data": {
│ "user_id": 101,
│ "name": "Raihan",
│ "token": "abc123xyz"
│ }
│ }
└────────────────────────────────────────────
┌┤ DioError │ Status: 401 Unauthorized │ Time: 180 ms
│ https://api.example.com/login
├────────────────────────────────────────────
│ Type: DioExceptionType.badResponse
├────────────────────────────────────────────
│ Body:
│ {
│ "success": false,
│ "message": "Invalid email or password"
│ }
└────────────────────────────────────────────
┌┤ DioError │ DioExceptionType.connectionTimeout
│ Connection timeout after 5000 ms
├────────────────────────────────────────────
│ Request:
│ https://api.example.com/login
└────────────────────────────────────────────
👨💻 Author #
Raihan Sikdar
Website: raihansikdar.com
Email: raihansikdar10@gmail.com
GitHub: raihansikdar
LinkedIn: raihansikdar
🤝 Contributing #
Contributions are welcome! Feel free to open issues or submit pull requests to improve this package.
📄 License #
This project is licensed under the MIT License.