generateTextMessage method

  1. @override
String generateTextMessage({
  1. TimeFormat timeFormat = TimeFormat.timeAndSeconds,
})

Internal method that generates a complete message about the event

See examples: TalkerLog -> TalkerLog.generateTextMessage TalkerException -> TalkerException.generateTextMessage TalkerError -> TalkerError.generateTextMessage

Implementation

@override
String generateTextMessage({
  TimeFormat timeFormat = TimeFormat.timeAndSeconds,
}) {
  var msg = '[$title] [${response.requestOptions.method}] $message';

  final responseMessage = response.statusMessage;
  final data = response.data;
  final headers = response.headers.map;

  msg += '\nStatus: ${response.statusCode}';

  if (settings.printResponseMessage && responseMessage != null) {
    msg += '\nMessage: $responseMessage';
  }

  try {
    if (settings.printResponseData && data != null) {
      final prettyData = _encoder.convert(data);
      msg += '\nData: $prettyData';
    }
    if (settings.printResponseHeaders && headers.isNotEmpty) {
      final prettyHeaders = _encoder.convert(headers);
      msg += '\nHeaders: $prettyHeaders';
    }
  } catch (_) {
    // TODO: add handling can`t convert
  }
  return msg;
}