Aus öffentlichen Paketdaten erstellte Orientierung.
Ein Dio-Interceptor, der die Debugging-Funktion durch das ansprechend formatierte Ausgeben von HTTP-Anfragen und -Antworten in der Konsole verbessert. Er hilft Entwicklern dabei, Datenfluss, Header und Statuscodes während der Entwicklung schnell zu überprüfen. Das Paket integriert sich nahtlos mit Dio, einem beliebten HTTP-Client für Dart, und unterstützt alle wichtigen Plattformen wie Android, iOS, Web, macOS, Windows und Linux. Ideal zum Troubleshooting von API-Interaktionen ohne externe Tools.
Anwendungsfälle
Debuggen von API-Aufrufen in der Entwicklung
Ansehen von Anfrage-/Antwort-Payloads
Überwachung von HTTP-Kopfzeilen und Statuscodes
Steigerung der Entwicklerproduktivität bei der API-Integration
Echtzeit-Protokollierung der Netzwerkaktivität
Hauptmerkmale
Formatierter JSON-Ausgabe
Unterstützt sowohl Anfragen als auch Antworten
Einfache Integration mit Dio
Plattformübergreifende Kompatibilität
Konfigurierbarer Protokolllevel
Minimale Einrichtung erforderlich
Geeignet für
Frontend-Entwickler, die Dio verwenden
Teams, die sich auf schnelle API-Debugging konzentrieren
Anwendungen, die eine transparente Netzwerkanalyse erfordern
Entwickler, die an RESTful-Diensten arbeiten
Projekte, bei denen Echtzeit-Konsolenprotokolle vorteilhaft sind
Hinweise
Nicht für Produktionsbuilds empfehlenswert
Kann die Leistung leicht beeinträchtigen aufgrund der Protokollierung
Benötigt manuelle Konfiguration, um im Release-Modus zu deaktivieren
Protokolle können sensible Daten preisgeben, wenn sie nicht gefiltert werden
Beschränkt auf Konsolenausgabe, keine Unterstützung für Datei- oder externe Protokollierung
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
A simple Dio interceptor for pretty printing the HTTP request/response (using the awesome
package Logger) to be printed in the console for easier debugging and sharing.
Different content types are supported and pretty printed such as:
application/json
application/x-www-form-urlencoded
text/html
Getting started
1- Install the package in your project:
flutter pub get dio_http_formatter
or if not for Flutter:
pub get dio_http_formatter
2- Add the interceptor to your Dio instance like:
final _dio = Dio();
_dio.interceptors.add(HttpFormatter());
Dio Version Map
For a certain version of Dio, use the following table to find the correct version of this package to use:
Dio Version
Package Version
4.x.x
2.x.x
5.x.x
3.x.x
Options
Below are the optional parameters that can be specified for the formatter to customize what and how the HTTP request and response is printed.
Property
Type
Default Value
includeRequest
bool
true
includeRequestHeaders
bool
true
includeRequestQueryParams
bool
true
includeRequestBody
bool
true
includeResponse
bool
true
includeResponseHeaders
bool
true
includeResponseBody
bool
true
logger
Logger
PrettyPrinter()
loggingFilter
LoggingFilter
null
Logging Filter
The HTTPFormatter has support for filtering whether to log a request/response or not. For example:
final dio = Dio();
dio.interceptors.add(
HttpFormatter(
loggingFilter: (request, response, error) {
// We don't want to print the request/response when 201 is returnedif (response?.statusCode == 201) {
returnfalse;
}
// Otherwise, the logs should printreturntrue;
},
),
);
[!WARNING] httpLoggerFilter is now deprecated and it's highly encouraged to move to the new loggingFilter. httpLoggerFilter will be removed in the next major version.