dio_ansi_logger 1.2.0
dio_ansi_logger: ^1.2.0 copied to clipboard
A beautiful, Postman-style Dio interceptor that logs HTTP requests and responses with ANSI colors, structured formatting, and customizable themes.
Changelog #
1.2.0 #
Added #
showCurloption onDioLogger— prints a formattedcurlcommand after each request, including method, URL, headers, and body (-dfor JSON,-Ffor FormData). Sensitive headers are automatically redacted whenredactHeadersis configured.logRetriesoption onDioLogger— prints a♻ Retry #Nline on each retry attempt. Requires the retry interceptor to incrementoptions.extra[kDioAnsiLoggerRetryCount]on each attempt.kDioAnsiLoggerRetryCount— a public constant exported from the package so retry interceptors can set the retry count without hardcoding the internal key string.
Changed #
onRequestnow conditionally renders the cURL block and retry line based on the new flags, with no impact on existing behaviour when both arefalse(the default).
1.1.1 #
- Fixed a
RangeErrorthrown by_colorizeJsonwhenmaxBodyLengthtruncates the response body mid-line, leaving a JSON key with no value (e.g."title":). Thesubstringcall now clamps its start index to the string length. - Fixed an
InterceptorStatesignal propagating out ofonRequest,onResponse, andonErrorwhen the interceptor is invoked outside a live Dio chain (e.g. in unit tests). The internalhandler.next()call is now guarded with a barecatchso the signal does not escape.
1.1.0 #
✨ Improvements & Fixes #
- Fixed timer collisions using unique request IDs (no conflicts in concurrent calls)
- Fixed timer leaks with automatic cleanup for stale timers (>60s)
- Added
logPrintcallback for custom logging (Talker, Firebase, etc.) - Added
requestFilter,responseFilter,errorFilterto silence specific endpoints - Added granular logging controls:
logRequestHeaderslogRequestBodylogResponseBody
- Improved FormData rendering (fields + file metadata instead of broken JSON)
- Fixed JSON colorizer (correct handling of URLs, timestamps,
:inside strings) - Added support for scientific notation numbers (
1e10,2.3E-4) - Extended HTTP method support (HEAD, OPTIONS, CONNECT, TRACE)
- URLs are now underlined in logs
🎨 Theme & ANSI Updates #
- Added underline support to themes
- Added
copyWith()toLoggerTheme - Updated all themes to support underline
- Expanded ANSI styles:
- italic, underline, strikethrough
- Background colors (
bgRed,bgGreen, etc.)
🧪 Tests #
- Expanded test suite from ~20 → 60+ tests
- Added coverage for:
- Filters
- FormData handling
- JSON edge cases
- Theme customization
- Custom logging (
logPrint)
1.0.9 #
- Made
enabledaconstfield; removed redundant innerconst.
1.0.8 #
- Added
logResponseHeadersparameter (defaultfalse) — response headers are now hidden by default as they are typically noisy
1.0.7 #
- Fixed static analysis: added curly braces to
ifstatements in_colorizeValueand_statusColor(lib/src/logger.dart)
1.0.6 #
✨ New Features #
-
Response time tracking — a
Time : ⏱ X msfield now appears on every RESPONSE ✓ and ERROR ✕ block showing the round-trip duration. Concurrent requests are timed independently so parallel calls never interfere with each other. Toggle withlogResponseTime(defaulttrue). -
Sensitive header redaction — header values whose keys match
redactedHeadersare replaced withredactedPlaceholderin both request and response logs. Matching is case-insensitive. Ships with safe defaults:authorization,x-api-key,cookie,set-cookie. Fully configurable — pass a custom set or{}to disable entirely.
⚙️ New DioLogger parameters #
| Parameter | Type | Default | Description |
|---|---|---|---|
logResponseTime |
bool |
true |
Show ⏱ elapsed ms on RESPONSE / ERROR |
redactedHeaders |
Set<String> |
{authorization, x-api-key, cookie, set-cookie} |
Header keys to mask |
redactedPlaceholder |
String |
[REDACTED] |
Replacement shown for masked headers |
1.0.5 #
- Fixed static analysis warning: added curly braces to while loop in AnsiLog._colorizeJson (lib/src/ansi_log.dart:218)
1.0.4 #
- Added
AnsiLog.enabled— global on/off switch, auto-off in release builds- Defaults to
!bool.fromEnvironment('dart.vm.product')— debug only - Set once in
main.dart:AnsiLog.enabled = kDebugMode; - All methods (
debug,info,success,warning,error,json) respect this flag
- Defaults to
- Added
AnsiLog.json(data)— pretty prints anyMaporListwith full ANSI syntax highlighting- Keys in cyan, strings in green, numbers in yellow, booleans in magenta, nulls in dim
- Supports custom
theme:andtag:parameters - Falls back to
debug()if data is not JSON-encodable
1.0.3 #
- Added
AnsiLog— a general-purpose static logger for use anywhere in your appAnsiLog.debug()— dim white, for verbose dev outputAnsiLog.info()— cyan, for general infoAnsiLog.success()— green, for successful operationsAnsiLog.warning()— yellow, for non-critical issuesAnsiLog.error()— red, with optionalerror:object- All methods support custom
theme:andtag:parameters
- Changed
DioLoggerfromfinal classtobase class— can now be extended outside the package - Added
///dartdoc comments toonRequest,onResponse, andonError - Fixed pub.dev documentation score (was <20%)
1.0.2 #
- Changed
DioLoggerfromfinal classtobase class— can now be extended outside the package
1.0.1 #
- Removed
flutterdependency — package is now pure Dart, works in Flutter, Dart CLI, and server apps - Replaced
kDebugModewithbool.fromEnvironment('dart.vm.product')for zero-dependency debug detection - Tightened
diolower bound to>=5.4.0to fix downgrade analysis failure (DioExceptionundefined) - Fixed ambiguous reexport warnings from dartdoc with
{@canonicalFor}annotations - Updated GitHub repository URLs
- Bumped version to
1.0.1
1.0.0 #
- Initial release 🎉
- Postman-style structured request / response / error logging
- ANSI color support for VS Code Debug Console & Unix terminals
- 4 built-in themes:
dark,minimal,solarized,nord matrixtheme — bright green on black 🟢- Fully customizable
LoggerThemewith per-field color control - Configurable body truncation via
maxBodyLength - Toggle
logRequest,logResponse,logErrorindependently - Pretty-printed, syntax-highlighted JSON output
- Zero dependencies beyond
dio