dio_ansi_logger 1.2.0 copy "dio_ansi_logger: ^1.2.0" to clipboard
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 #

  • showCurl option on DioLogger — prints a formatted curl command after each request, including method, URL, headers, and body (-d for JSON, -F for FormData). Sensitive headers are automatically redacted when redactHeaders is configured.
  • logRetries option on DioLogger — prints a ♻ Retry #N line on each retry attempt. Requires the retry interceptor to increment options.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 #

  • onRequest now conditionally renders the cURL block and retry line based on the new flags, with no impact on existing behaviour when both are false (the default).

1.1.1 #

  • Fixed a RangeError thrown by _colorizeJson when maxBodyLength truncates the response body mid-line, leaving a JSON key with no value (e.g. "title":). The substring call now clamps its start index to the string length.
  • Fixed an InterceptorState signal propagating out of onRequest, onResponse, and onError when the interceptor is invoked outside a live Dio chain (e.g. in unit tests). The internal handler.next() call is now guarded with a bare catch so 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 logPrint callback for custom logging (Talker, Firebase, etc.)
  • Added requestFilter, responseFilter, errorFilter to silence specific endpoints
  • Added granular logging controls:
    • logRequestHeaders
    • logRequestBody
    • logResponseBody
  • 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() to LoggerTheme
  • 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 enabled a const field; removed redundant inner const.

1.0.8 #

  • Added logResponseHeaders parameter (default false) — response headers are now hidden by default as they are typically noisy

1.0.7 #

  • Fixed static analysis: added curly braces to if statements in _colorizeValue and _statusColor (lib/src/logger.dart)

1.0.6 #

✨ New Features #

  • Response time tracking — a Time : ⏱ X ms field 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 with logResponseTime (default true).

  • Sensitive header redaction — header values whose keys match redactedHeaders are replaced with redactedPlaceholder in 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
  • Added AnsiLog.json(data) — pretty prints any Map or List with full ANSI syntax highlighting
    • Keys in cyan, strings in green, numbers in yellow, booleans in magenta, nulls in dim
    • Supports custom theme: and tag: 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 app
    • AnsiLog.debug() — dim white, for verbose dev output
    • AnsiLog.info() — cyan, for general info
    • AnsiLog.success() — green, for successful operations
    • AnsiLog.warning() — yellow, for non-critical issues
    • AnsiLog.error() — red, with optional error: object
    • All methods support custom theme: and tag: parameters
  • Changed DioLogger from final class to base class — can now be extended outside the package
  • Added /// dartdoc comments to onRequest, onResponse, and onError
  • Fixed pub.dev documentation score (was <20%)

1.0.2 #

  • Changed DioLogger from final class to base class — can now be extended outside the package

1.0.1 #

  • Removed flutter dependency — package is now pure Dart, works in Flutter, Dart CLI, and server apps
  • Replaced kDebugMode with bool.fromEnvironment('dart.vm.product') for zero-dependency debug detection
  • Tightened dio lower bound to >=5.4.0 to fix downgrade analysis failure (DioException undefined)
  • 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
  • matrix theme — bright green on black 🟢
  • Fully customizable LoggerTheme with per-field color control
  • Configurable body truncation via maxBodyLength
  • Toggle logRequest, logResponse, logError independently
  • Pretty-printed, syntax-highlighted JSON output
  • Zero dependencies beyond dio
1
likes
160
points
363
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A beautiful, Postman-style Dio interceptor that logs HTTP requests and responses with ANSI colors, structured formatting, and customizable themes.

Repository (GitHub)
View/report issues

Topics

#dio #networking #logging #http #debug

License

MIT (license)

Dependencies

dio

More

Packages that depend on dio_ansi_logger