chic_http_logger 0.1.0
chic_http_logger: ^0.1.0 copied to clipboard
A pretty, boxed console logger for package:http — request/response headers, bodies, status, and timing rendered like pretty_dio_logger, with zero Flutter dependency.
chic_http_logger #
A pretty, boxed console logger for package:http — request/response
headers, bodies, status codes, and timing rendered in the same boxed style as
pretty_dio_logger, but for the plain http package and
with zero Flutter dependency.
╔ Request ║ POST
║ https://example.com/api/users
╚══════════════════════════════════════════════════════════════════════════════════
╔ Headers
║ content-type: application/json
╚══════════════════════════════════════════════════════════════════════════════════
╔ Body
║ {"name":"morpheus"}
╚══════════════════════════════════════════════════════════════════════════════════
╔ Response ║ POST ║ Status: 201 ║ Time: 214 ms
║ https://example.com/api/users
╚══════════════════════════════════════════════════════════════════════════════════
╔ Body
║ {"id":42,"name":"morpheus"}
╚══════════════════════════════════════════════════════════════════════════════════
Status and method lines are color-coded (green for 2xx, orange for 4xx, red for 5xx and errors) when your console supports ANSI.
Install #
dart pub add chic_http_logger # or: flutter pub add chic_http_logger
Usage #
ChicHttpLogger is an http.Client decorator — wrap the client you already
use and call it exactly the same way:
import 'package:chic_http_logger/chic_http_logger.dart';
import 'package:http/http.dart' as http;
final client = ChicHttpLogger(innerClient: http.Client());
final response = await client.get(Uri.parse('https://example.com'));
client.close(); // closes the wrapped client too
Because responses are fully buffered in order to log them, avoid wrapping a client used for very large downloads.
Security #
mode defaults to LogMode.auto, which silences all logging in release
builds (detected via dart.vm.product) so headers, tokens, and bodies never
reach a production console. Pass LogMode.always or LogMode.never to
override that.
Options #
| Option | Default | Description |
|---|---|---|
mode |
LogMode.auto |
Whether logging is active at all (see above) |
requestHeaders |
true |
Log request headers |
requestBody |
true |
Log the request body |
responseHeaders |
false |
Log response headers |
responseBody |
true |
Log the response body |
error |
true |
Log a block when the request throws |
compact |
true |
Minify JSON bodies onto one line; false pretty-prints with indentation |
maxWidth |
90 |
Column width each line wraps to |
colors |
true |
Colorize output with ANSI escape codes |
logPrint |
print |
Sink each printed line is sent to |
Multipart requests log field names/values and file metadata only (never file
contents); binary or non-UTF-8 bodies print as <N bytes, binary or non-UTF-8 body> instead of being dumped raw.