toDebugString method
A string that represents more details about the request, typically used for logging.
Note: Setting includeRequestIP to true creates a significant performance penalty.
Implementation
String toDebugString({
bool includeElapsedTime = true,
bool includeRequestIP = false,
bool includeMethod = true,
bool includeResource = true,
bool includeStatusCode = true,
bool includeContentSize = false,
bool includeHeaders = false,
}) {
final builder = StringBuffer();
if (includeRequestIP) {
builder.write("${raw.connectionInfo?.remoteAddress.address} ");
}
if (includeMethod) {
builder.write("${raw.method} ");
}
if (includeResource) {
builder.write("${raw.uri} ");
}
if (includeElapsedTime && respondDate != null) {
builder
.write("${respondDate!.difference(receivedDate).inMilliseconds}ms ");
}
if (includeStatusCode) {
builder.write("${raw.response.statusCode} ");
}
if (includeContentSize) {
builder.write("${raw.response.contentLength} ");
}
if (includeHeaders) {
builder.write("$_sanitizedHeaders ");
}
return builder.toString();
}