logError static method

void logError({
  1. required String url,
  2. required String error,
  3. int? statusCode,
  4. dynamic body,
  5. String? requestId,
})

Implementation

static void logError({
  required String url,
  required String error,
  int? statusCode,
  dynamic body,
  String? requestId,
}) {
  if (!_enabled) return;
  final id = requestId != null ? ' $_gray[$requestId]$_reset' : '';
  _line(_red);
  _print('$_red│$_reset $_bold${_red}💥 ERROR$id$_reset  $_gray${_ts()}$_reset');
  _print('$_red│$_reset  $_blue$url$_reset');
  if (statusCode != null) _print('$_red│$_reset  ${_bold}Status: $statusCode$_reset');
  _print('$_red│$_reset  $_red$error$_reset');
  if (_printPayload && body != null) {
    _print('$_red│$_reset  $_yellow⊳ Error Body$_reset');
    _formatJson(body).split('\n').forEach((l) =>
        _print('$_red│$_reset    $_white$l$_reset'));
  }
  _line(_red);
}