MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / CreateMessageJson

Method CreateMessageJson

layers/error_message/logging.cpp:323–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323std::string DebugReport::CreateMessageJson(VkFlags msg_flags, const Location& loc,
324 const std::vector<VkDebugUtilsObjectNameInfoEXT>& object_name_infos,
325 const uint32_t vuid_hash, std::string_view vuid_text, const std::string& main_message,
326 bool at_message_limit) {
327 std::ostringstream oss;
328 // For now we just list each JSON field as a new line as it is "pretty-print enough".
329 // For Android, things get logged in logcat and having the JSON as a single line is easier to grab from the terminal.
330#ifdef VK_USE_PLATFORM_ANDROID_KHR
331 char new_line = ' ';
332 char line_start = ' ';
333#else
334 char new_line = '\n';
335 char line_start = '\t';
336#endif
337
338 oss << "{" << new_line;
339
340 if (message_format_settings.display_application_name && !message_format_settings.application_name.empty()) {
341 oss << line_start << "\"AppName\" : \"" << message_format_settings.application_name << "\"," << new_line;
342 }
343
344 {
345 oss << line_start << "\"Severity\" : \"";
346 if (msg_flags & kErrorBit) {
347 oss << "Error";
348 } else if (msg_flags & kWarningBit) {
349 oss << "Warning";
350 } else if (msg_flags & kPerformanceWarningBit) {
351 oss << "Performance Warning";
352 } else if (msg_flags & kInformationBit) {
353 oss << "Information";
354 } else if (msg_flags & kVerboseBit) {
355 oss << "Verbose";
356 }
357 oss << "\"," << new_line;
358 }
359
360 {
361 oss << line_start << "\"VUID\" : \"" << vuid_text << "\"," << new_line;
362 }
363
364 {
365 oss << line_start << "\"Objects\" : [" << new_line;
366 for (uint32_t i = 0; i < object_name_infos.size(); i++) {
367 const VkDebugUtilsObjectNameInfoEXT& src_object = object_name_infos[i];
368
369 oss << line_start << line_start;
370 oss << "{\"type\" : \"" << string_VkObjectTypeHandleName(src_object.objectType) << "\", \"handle\" : \"";
371 if (0 != src_object.objectHandle) {
372 oss << "0x" << std::hex << src_object.objectHandle;
373 oss << "\", \"name\" : \"";
374 if (src_object.pObjectName) {
375 oss << src_object.pObjectName;
376 }
377 oss << "\"}";
378 } else {
379 oss << "VK_NULL_HANDLE\", \"name\" : \"\"}";
380 }

Callers

nothing calls this directly

Calls 8

StringFuncMethod · 0.80
FieldsMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected