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] [${requestOptions.method}] $message';

  final data = requestOptions.data;
  final headers = requestOptions.headers;

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