Skip to content

Commit 1c55a12

Browse files
authored
Merge pull request #262 from ChristophHaag/cout_default
layers/core_validation: Default to stdout logging
2 parents 8817420 + bc3cd82 commit 1c55a12

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
validation layer: Set default logging mode to stdout ("text") instead of none.

src/api_layers/README_core_validation.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@ There are three modes currently supported:
3131
3. Output HTML content to a file
3232
4. Output to the application using the `XR_EXT_debug_utils` extension
3333

34-
Core Validation API layer does not output content by default. In order to output
35-
to either stdout or a file, you must use the following environmental variables:
34+
Core Validation API layer outputs content to stdout by default.
3635

37-
* `XR_CORE_VALIDATION_EXPORT_TYPE`
38-
* `XR_CORE_VALIDATION_FILE_NAME`
39-
40-
`XR_CORE_VALIDATION_EXPORT_TYPE` is used to define the type of output from
36+
`XR_CORE_VALIDATION_EXPORT_TYPE` is used to change the type of output from
4137
the API layer. Currently, this can be set to the following:
4238

43-
* `text` : This will generate standard text output.
4439
* `html` : This will generate HTML formatted content.
40+
* `none` : This will disable output.
4541

4642
`XR_CORE_VALIDATION_FILE_NAME` is used to define the file name that is
4743
written to. If not defined, the information goes to stdout. If defined,

src/api_layers/core_validation.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,36 +481,33 @@ XRAPI_ATTR XrResult XRAPI_CALL CoreValidationXrCreateApiLayerInstance(const XrIn
481481

482482
if (!g_record_info.initialized) {
483483
g_record_info.initialized = true;
484-
g_record_info.type = RECORD_NONE;
484+
g_record_info.type = RECORD_TEXT_COUT;
485485
}
486486

487487
std::string export_type = PlatformUtilsGetEnv("XR_CORE_VALIDATION_EXPORT_TYPE");
488488
std::string file_name = PlatformUtilsGetEnv("XR_CORE_VALIDATION_FILE_NAME");
489489
if (!file_name.empty()) {
490490
g_record_info.file_name = file_name;
491+
g_record_info.type = RECORD_TEXT_FILE;
492+
user_defined_output = true;
491493
}
492494

493495
if (!export_type.empty()) {
494496
std::string export_type_lower = export_type;
495497
std::transform(export_type.begin(), export_type.end(), export_type_lower.begin(),
496498
[](unsigned char c) { return std::tolower(c); });
497499

498-
std::cerr << "Core Validation output type: " << export_type_lower
499-
<< ", first time = " << (first_time ? "true" : "false") << std::endl;
500-
if (export_type_lower == "text") {
501-
if (!g_record_info.file_name.empty()) {
502-
g_record_info.type = RECORD_TEXT_FILE;
503-
} else {
504-
g_record_info.type = RECORD_TEXT_COUT;
505-
}
506-
user_defined_output = true;
507-
} else if (export_type_lower == "html" && first_time) {
500+
if (export_type_lower == "html" && first_time) {
508501
g_record_info.type = RECORD_HTML_FILE;
509502
if (!CoreValidationWriteHtmlHeader()) {
510503
return XR_ERROR_INITIALIZATION_FAILED;
511504
}
505+
} else if (export_type_lower == "none") {
506+
g_record_info.type = RECORD_NONE;
512507
}
513508
}
509+
std::cerr << "Core Validation output type: " << (export_type.empty() ? "text" : export_type)
510+
<< ", first time = " << (first_time ? "true" : "false") << std::endl;
514511

515512
// Call the generated pre valid usage check.
516513
validation_result = GenValidUsageInputsXrCreateInstance(info, instance);

0 commit comments

Comments
 (0)