bugfix: debug mask

This commit is contained in:
2026-04-12 11:08:32 -05:00
parent 6d34dfc58f
commit f032f152a9
4 changed files with 5 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ $ ./build/ouros
``` ```
For control on debugging: For control on debugging:
```bash ```bash
$ ./build/ouros --debug 0b00111111 $ ./build/ouros --debug=0b00111111
``` ```
where each bit in the mask corresponds to a debug level, in order: unused, unused, fatal, trace, error, warning, notice, and info. `0b1111111` enables all debug messages. where each bit in the mask corresponds to a debug level, in order: unused, unused, fatal, trace, error, warning, notice, and info. `0b1111111` enables all debug messages.

View File

@@ -34,8 +34,7 @@ void Engine::exec() {
}; };
VkInstance instance; VkInstance instance;
VkResult result = vkCreateInstance(&instanceCI, nullptr, &instance); if(vkCreateInstance(&instanceCI, nullptr, &instance) == VK_SUCCESS) {
if(result == VK_SUCCESS) {
utils::debugPrint(__FUNCTION__, __LINE__, "Vulkan instance successfully created.", utils::DebugLevel::Info); utils::debugPrint(__FUNCTION__, __LINE__, "Vulkan instance successfully created.", utils::DebugLevel::Info);
} else { } else {
utils::debugPrint(__FUNCTION__, __LINE__, "Error creating Vulkan instance", utils::DebugLevel::Error); utils::debugPrint(__FUNCTION__, __LINE__, "Error creating Vulkan instance", utils::DebugLevel::Error);

View File

@@ -16,6 +16,7 @@ public:
private: private:
// might get rid of this
void init(); void init();
// TODO: smart pointers probably would be smart // TODO: smart pointers probably would be smart

View File

@@ -37,7 +37,7 @@ namespace utils {
static void debugPrint(const char* function, int line, std::string message, size_t debugLevel) { static void debugPrint(const char* function, int line, std::string message, size_t debugLevel) {
if(!(debugMask >> debugLevel)) return; // then ignore this debug level if(!((debugMask >> debugLevel) & 1)) return; // then ignore this debug level
std::cout << "[ " << std::left << std::setw(16) << function << ": " << std::right << std::setw(4) << line << ", " << std::left << std::setw(8) << debugTypeStrings[debugLevel] << " ] " << message << std::endl; std::cout << "[ " << std::left << std::setw(16) << function << ": " << std::right << std::setw(4) << line << ", " << std::left << std::setw(8) << debugTypeStrings[debugLevel] << " ] " << message << std::endl;
// TODO: add timestamps // TODO: add timestamps
@@ -53,6 +53,7 @@ namespace utils {
std::cout << "Unsupported debug key." << std::endl; std::cout << "Unsupported debug key." << std::endl;
} }
debugMask = static_cast<uint8_t>(std::stoul(value, nullptr, 2)); // interpret a string as a uint debugMask = static_cast<uint8_t>(std::stoul(value, nullptr, 2)); // interpret a string as a uint
} }
} }